[gnome-robots] move color procedures to graphics module
- From: Andrey Kutejko <akutejko src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-robots] move color procedures to graphics module
- Date: Tue, 6 Oct 2020 19:31:41 +0000 (UTC)
commit 4cbe72361009803d6e6caef2e8040d59e7a8736b
Author: Andrey Kutejko <andy128k gmail com>
Date: Thu Sep 17 02:18:23 2020 +0200
move color procedures to graphics module
src/game.vala | 6 ++----
src/graphics.vala | 24 +++++++++++++-----------
src/properties.vala | 17 ++---------------
3 files changed, 17 insertions(+), 30 deletions(-)
---
diff --git a/src/game.vala b/src/game.vala
index 3a3c498..25df6fd 100644
--- a/src/game.vala
+++ b/src/game.vala
@@ -371,7 +371,7 @@ public class Game {
bool timeout_cb () {
game_area.tick ();
- clear_game_area ();
+ game_area.queue_draw ();
if ((state == State.TYPE2) || (state == State.WTYPE2)) {
move_type2_robots ();
@@ -389,7 +389,6 @@ public class Game {
++endlev_counter;
if (endlev_counter >= CHANGE_DELAY) {
++current_level;
- clear_game_area ();
generate_level ();
state = State.PLAYING;
set_move_action_sensitivity (true);
@@ -462,9 +461,8 @@ public class Game {
safe_teleports = config.initial_safe_teleports;
splat = null;
- game_area.queue_draw ();
generate_level ();
- clear_game_area ();
+ game_area.queue_draw ();
state = State.PLAYING;
diff --git a/src/graphics.vala b/src/graphics.vala
index 83a7ec8..828156b 100644
--- a/src/graphics.vala
+++ b/src/graphics.vala
@@ -17,10 +17,22 @@
* For more details see the file COPYING.
*/
-using Gtk;
using Gdk;
using Cairo;
+public RGBA string_to_rgba (string color) {
+ RGBA rgba = RGBA ();
+ rgba.parse (color);
+ return rgba;
+}
+
+public string rgba_to_string (RGBA color) {
+ return "#%04x%04x%04x".printf (
+ (int) (color.red * 65535 + 0.5),
+ (int) (color.green * 65535 + 0.5),
+ (int) (color.blue * 65535 + 0.5));
+}
+
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. */
@@ -47,13 +59,3 @@ public RGBA calculate_light_color (RGBA color) {
return light;
}
-/**
- * clears the whole of the game area
- **/
-public void clear_game_area () {
- if (game_area == null)
- return;
-
- game_area.queue_draw ();
-}
-
diff --git a/src/properties.vala b/src/properties.vala
index 13d69c2..8acb6d7 100644
--- a/src/properties.vala
+++ b/src/properties.vala
@@ -80,7 +80,7 @@ void pmap_selection (ComboBox combo) {
} catch (Error e) {
// TODO
}
- clear_game_area ();
+ game_area.queue_draw ();
}
}
@@ -145,8 +145,8 @@ ComboBox create_theme_picker (Themes themes, string current_theme) {
void bg_color_callback (ColorChooser color_chooser) {
properties.bgcolour = color_chooser.get_rgba ();
game_area.background_color = properties.bgcolour;
- clear_game_area ();
conf_set_background_color (properties.bgcolour);
+ game_area.queue_draw ();
}
public string properties_theme_name () {
@@ -326,19 +326,6 @@ public Theme get_theme_from_properties () throws Error {
return new Theme.from_file (theme_path);
}
-RGBA string_to_rgba (string color) {
- RGBA rgba = RGBA ();
- rgba.parse (color);
- return rgba;
-}
-
-public string rgba_to_string (RGBA color) {
- return "#%04x%04x%04x".printf (
- (int) (color.red * 65535 + 0.5),
- (int) (color.green * 65535 + 0.5),
- (int) (color.blue * 65535 + 0.5));
-}
-
public void conf_set_theme (string val) {
settings.set_string (KEY_THEME, val);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]