[gnome-robots/issue_17] Look for a game config by a name and by description. Fallback to a first available config.
- From: Andrey Kutejko <akutejko src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-robots/issue_17] Look for a game config by a name and by description. Fallback to a first available config.
- Date: Sat, 16 Jan 2021 01:10:46 +0000 (UTC)
commit 202af430c9e1d3edb17f2f51b4ed33d9a0075b87
Author: Andrey Kutejko <andy128k gmail com>
Date: Sat Jan 16 02:09:34 2021 +0100
Look for a game config by a name and by description. Fallback to a first available config.
src/game-area.vala | 2 +-
src/game-config.vala | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/src/game-area.vala b/src/game-area.vala
index 2d0116b..6083786 100644
--- a/src/game-area.vala
+++ b/src/game-area.vala
@@ -96,7 +96,7 @@ public class GameArea : DrawingArea {
this.sound_player = sound_player;
this.properties = properties;
- game.config = game_configs.find_by_name (properties.selected_config);
+ game.config = game_configs.find_by_name (properties.selected_config) ?? game_configs[0];
add_events (Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK |
Gdk.EventMask.POINTER_MOTION_MASK);
configure_event.connect (event => resize_cb (event));
diff --git a/src/game-config.vala b/src/game-config.vala
index e9c9a32..1c819bd 100644
--- a/src/game-config.vala
+++ b/src/game-config.vala
@@ -194,7 +194,7 @@ public class GameConfigs {
public GameConfig? find_by_name (string name) {
for (var i = 0; i < game_configs.size; ++i) {
- if (game_configs[i].name () == name) {
+ if (game_configs[i].description == name || game_configs[i].name () == name) {
return game_configs[i];
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]