[gnome-robots] move bubbles to GameArea
- From: Andrey Kutejko <akutejko src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-robots] move bubbles to GameArea
- Date: Tue, 6 Oct 2020 19:31:41 +0000 (UTC)
commit 0f0ce750f804cd265f53be9aaf84fbc143826c1a
Author: Andrey Kutejko <andy128k gmail com>
Date: Sun Sep 13 18:48:10 2020 +0200
move bubbles to GameArea
src/game-area.vala | 13 ++++++++++++-
src/graphics.vala | 10 ----------
src/properties.vala | 1 -
src/robots.vala | 27 ++++++++++++++-------------
4 files changed, 26 insertions(+), 25 deletions(-)
---
diff --git a/src/game-area.vala b/src/game-area.vala
index 2639847..8fd1ef0 100644
--- a/src/game-area.vala
+++ b/src/game-area.vala
@@ -32,6 +32,9 @@ public class GameArea : DrawingArea {
private Theme _theme;
private RGBA light_background;
private RGBA dark_background;
+ private Bubble aieee_bubble;
+ private Bubble yahoo_bubble;
+ private Bubble splat_bubble;
private Animated player_animation;
private Animated player_dead_animation;
@@ -69,10 +72,18 @@ public class GameArea : DrawingArea {
}
}
- public GameArea (Game game, Theme theme) {
+ public GameArea (Game game,
+ Theme theme,
+ Bubble aieee_bubble,
+ Bubble yahoo_bubble,
+ Bubble splat_bubble
+ ) {
this.game = game;
this.theme = theme;
this.background_color_name = "#7590AE";
+ this.aieee_bubble = aieee_bubble;
+ this.yahoo_bubble = yahoo_bubble;
+ this.splat_bubble = splat_bubble;
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/graphics.vala b/src/graphics.vala
index 4a171a2..8637d85 100644
--- a/src/graphics.vala
+++ b/src/graphics.vala
@@ -30,16 +30,6 @@ public const int GAME_HEIGHT = 30;
public int tile_width = 0;
public int tile_height = 0;
-Bubble aieee_bubble = null;
-Bubble yahoo_bubble = null;
-Bubble splat_bubble = null;
-
-public void load_game_graphics () throws Error {
- yahoo_bubble = new Bubble.from_data_file ("yahoo.png");
- aieee_bubble = new Bubble.from_data_file ("aieee.png");
- splat_bubble = new Bubble.from_data_file ("splat.png");
-}
-
public RGBA calculate_light_color (RGBA color) {
/* While the two colours are labelled "light" and "dark" which one is
* which actually depends on how light or dark the base colour is. */
diff --git a/src/properties.vala b/src/properties.vala
index 7c3546f..13d69c2 100644
--- a/src/properties.vala
+++ b/src/properties.vala
@@ -77,7 +77,6 @@ void pmap_selection (ComboBox combo) {
try {
game_area.theme = new Theme.from_file (theme_path);
- load_game_graphics ();
} catch (Error e) {
// TODO
}
diff --git a/src/robots.vala b/src/robots.vala
index b1594a1..46a1d70 100644
--- a/src/robots.vala
+++ b/src/robots.vala
@@ -303,15 +303,25 @@ void activate (Gtk.Application app) {
window.add_action_entries (win_entries, app);
Theme theme = null;
+ Bubble aieee_bubble = null;
+ Bubble yahoo_bubble = null;
+ Bubble splat_bubble = null;
try {
theme = get_theme_from_properties ();
+ yahoo_bubble = new Bubble.from_data_file ("yahoo.png");
+ aieee_bubble = new Bubble.from_data_file ("aieee.png");
+ splat_bubble = new Bubble.from_data_file ("splat.png");
} catch (Error e) {
- // error ("%s", e.message);
+ critical ("%s", e.message);
// TODO message box
app.quit ();
}
- game_area = new GameArea (game, theme);
+ game_area = new GameArea (game,
+ theme,
+ aieee_bubble,
+ yahoo_bubble,
+ splat_bubble);
game_area.destroy.connect (() => game_area = null);
var gridframe = new Games.GridFrame (GAME_WIDTH, GAME_HEIGHT);
@@ -391,18 +401,9 @@ void activate (Gtk.Application app) {
app.quit ();
}
- try {
- game_area.background_color = properties.bgcolour;
-
- load_game_graphics ();
-
- keyboard_set (properties.keys);
- } catch (Error e) {
- // error ("%s", e.message);
- // TODO message box
- app.quit ();
- }
+ game_area.background_color = properties.bgcolour;
+ keyboard_set (properties.keys);
init_keyboard ();
game.config = game_configs.find_by_name (properties.selected_config);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]