[lightsoff] Remove the LED array
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [lightsoff] Remove the LED array
- Date: Sun, 17 Aug 2014 20:20:03 +0000 (UTC)
commit 6b59a05f4ad25c253ffd8e923f76638fcdd8ebb5
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sat Aug 16 11:01:43 2014 -0500
Remove the LED array
Use left and right buttons in the header bar instead. The LED was
reported to be too confusing (it's not clearly a level) and also too
difficult to read compared to normal font.
https://bugzilla.gnome.org/show_bug.cgi?id=734911
data/Makefile.am | 3 -
data/arrow.svg | 66 ----------------
data/backing.svg | 141 ----------------------------------
data/led-back.svg | 117 ----------------------------
data/org.gnome.lightsoff.gschema.xml | 1 +
src/Makefile.am | 1 -
src/game-view.vala | 82 +-------------------
src/led-array.vala | 141 ----------------------------------
src/lightsoff.vala | 60 +++++++++++++--
9 files changed, 57 insertions(+), 555 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index 120ae8b..49d3a28 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -2,9 +2,6 @@ SUBDIRS = icons
lightsoffdir = $(datadir)/lightsoff
lightsoff_DATA = \
- arrow.svg \
- backing.svg \
- led-back.svg \
off.svg \
on.svg \
highlight.svg
diff --git a/data/org.gnome.lightsoff.gschema.xml b/data/org.gnome.lightsoff.gschema.xml
index fbcfefc..dfcb564 100644
--- a/data/org.gnome.lightsoff.gschema.xml
+++ b/data/org.gnome.lightsoff.gschema.xml
@@ -2,6 +2,7 @@
<schema id="org.gnome.lightsoff" path="/org/gnome/lightsoff/" gettext-domain="lightsoff">
<key name="level" type="i">
<default>1</default>
+ <range min="1" />
<summary>The current level</summary>
<description>The users's most recent level.</description>
</key>
diff --git a/src/Makefile.am b/src/Makefile.am
index 4a93960..284c7c2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,7 +4,6 @@ lightsoff_SOURCES = \
board-view.vala \
config.vapi \
lightsoff.vala \
- led-array.vala \
puzzle-generator.vala \
game-view.vala
diff --git a/src/game-view.vala b/src/game-view.vala
index 9b9a9a6..b2348cc 100644
--- a/src/game-view.vala
+++ b/src/game-view.vala
@@ -15,24 +15,17 @@ public void setup_animation (Clutter.Actor actor, Clutter.AnimationMode mode, ui
public class GameView : Clutter.Group
{
- private Clutter.Texture backing_texture;
private Clutter.Texture highlight_texture;
private Clutter.Texture off_texture;
private Clutter.Texture on_texture;
- private Clutter.Texture led_back_texture;
- private Clutter.Texture arrow_texture;
private int current_level;
private List<Clutter.Actor> actor_remove_queue = null;
- private LEDArray score_view;
private Clutter.Actor board_group;
private BoardView board_view;
private BoardView? new_board_view = null;
- private Clutter.Actor backing_view;
- private Clutter.Actor left_arrow;
- private Clutter.Actor right_arrow;
private Clutter.Actor key_cursor_view;
private Clutter.Timeline timeline;
@@ -50,12 +43,9 @@ public class GameView : Clutter.Group
{
try
{
- backing_texture = new Clutter.Texture.from_file (Path.build_filename (DATADIR, "backing.svg"));
highlight_texture = new Clutter.Texture.from_file (Path.build_filename (DATADIR,
"highlight.svg"));
off_texture = new Clutter.Texture.from_file (Path.build_filename (DATADIR, "off.svg"));
on_texture = new Clutter.Texture.from_file (Path.build_filename (DATADIR, "on.svg"));
- led_back_texture = new Clutter.Texture.from_file (Path.build_filename (DATADIR, "led-back.svg"));
- arrow_texture = new Clutter.Texture.from_file (Path.build_filename (DATADIR, "arrow.svg"));
}
catch (Clutter.TextureError e)
{
@@ -63,21 +53,12 @@ public class GameView : Clutter.Group
}
/* Add textures onto the scene so they can be cloned */
- backing_texture.hide ();
- add_child (backing_texture);
highlight_texture.hide ();
add_child (highlight_texture);
off_texture.hide ();
add_child (off_texture);
on_texture.hide ();
add_child (on_texture);
- led_back_texture.hide ();
- add_child (led_back_texture);
- arrow_texture.hide ();
- add_child (arrow_texture);
-
- var real_board_width = 5 * off_texture.width + 4;
- var real_board_height = 5 * off_texture.height + 4;
board_group = new Clutter.Actor ();
add_child (board_group);
@@ -87,34 +68,9 @@ public class GameView : Clutter.Group
board_view.playable = true;
board_group.add_child (board_view);
- backing_view = new Clutter.Clone (backing_texture);
- backing_view.set_position (0, real_board_height);
- add_child (backing_view);
-
- score_view = new LEDArray (5, led_back_texture);
- score_view.value = current_level;
- score_view.set_anchor_point (score_view.width / 2, 0);
- score_view.set_position (real_board_width / 2, real_board_height + 18);
- add_child (score_view);
-
- set_size (real_board_width, score_view.y + score_view.height);
-
- left_arrow = new Clutter.Clone (arrow_texture);
- left_arrow.anchor_gravity = Clutter.Gravity.CENTER;
- left_arrow.reactive = true;
- left_arrow.button_release_event.connect (left_arrow_button_release_cb);
- left_arrow.touch_event.connect (left_arrow_touch_event_cb);
- left_arrow.set_position ((score_view.x - score_view.anchor_x) / 2, score_view.y + (score_view.height
/ 2) - 10);
- add_child (left_arrow);
-
- right_arrow = new Clutter.Clone (arrow_texture);
- right_arrow.anchor_gravity = Clutter.Gravity.CENTER;
- right_arrow.reactive = true;
- right_arrow.button_release_event.connect (right_arrow_button_release_cb);
- right_arrow.touch_event.connect (right_arrow_touch_event_cb);
- right_arrow.rotation_angle_y = 180;
- right_arrow.set_position (real_board_width - left_arrow.x, score_view.y + (score_view.height / 2) -
10);
- add_child (right_arrow);
+ var real_board_width = 5 * off_texture.width + 4;
+ var real_board_height = 5 * off_texture.height + 4;
+ set_size (real_board_width, real_board_height);
key_cursor_view = new Clutter.Clone (highlight_texture);
key_cursor_view.set_position (-100, -100);
@@ -155,7 +111,6 @@ public class GameView : Clutter.Group
return;
current_level++;
- score_view.value = current_level;
// Make sure the board transition is different than the previous.
var direction = 0;
@@ -180,37 +135,11 @@ public class GameView : Clutter.Group
level_changed (current_level);
}
- private bool left_arrow_touch_event_cb (Clutter.Actor actor, Clutter.Event event)
- {
- if (event.type == Clutter.EventType.TOUCH_END)
- swap_board (-1);
- return false;
- }
-
- private bool right_arrow_touch_event_cb (Clutter.Actor actor, Clutter.Event event)
- {
- if (event.type == Clutter.EventType.TOUCH_END)
- swap_board (1);
- return false;
- }
-
- private bool left_arrow_button_release_cb (Clutter.Actor actor, Clutter.ButtonEvent event)
- {
- swap_board (-1);
- return false;
- }
-
- private bool right_arrow_button_release_cb (Clutter.Actor actor, Clutter.ButtonEvent event)
- {
- swap_board (1);
- return false;
- }
-
// The player asked to swap to a different level without completing
// the one in progress; this can occur either by clicking an arrow
// or by requesting a new game from the menu. Animate the new board
// in, depthwise, in the direction indicated by 'context'.
- private void swap_board (int direction)
+ public void swap_board (int direction)
{
if (timeline != null && timeline.is_playing ())
return;
@@ -222,8 +151,6 @@ public class GameView : Clutter.Group
return;
}
- score_view.value = current_level;
-
timeline = new Clutter.Timeline (500);
new_board_view = create_board_view (current_level);
@@ -288,7 +215,6 @@ public class GameView : Clutter.Group
return;
current_level = 1;
- score_view.value = current_level;
timeline = new Clutter.Timeline (500);
diff --git a/src/lightsoff.vala b/src/lightsoff.vala
index 349256b..287a394 100644
--- a/src/lightsoff.vala
+++ b/src/lightsoff.vala
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010-2013 Robert Ancell
+ * Copyright (C) 2014 Michael Catanzaro
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
@@ -11,16 +12,23 @@
public class LightsOff : Gtk.Application
{
private Settings settings;
- private Gtk.Window window;
+ private Gtk.ApplicationWindow window;
+ private Gtk.HeaderBar headerbar;
private GameView game_view;
private const GLib.ActionEntry[] action_entries =
{
- { "new-game", new_game_cb },
{ "quit", quit_cb },
{ "help", help_cb },
{ "about", about_cb }
};
+
+ private const ActionEntry[] window_actions =
+ {
+ { "new-game", new_game_cb },
+ { "previous-level", previous_level_cb },
+ { "next-level", next_level_cb }
+ };
private LightsOff ()
{
@@ -34,14 +42,14 @@ public class LightsOff : Gtk.Application
Gtk.Settings.get_default ().set ("gtk-application-prefer-dark-theme", true);
add_action_entries (action_entries, this);
- add_accelerator ("<Primary>n", "app.new-game", null);
+ add_accelerator ("<Primary>n", "win.new-game", null);
add_accelerator ("F1", "app.help", null);
add_accelerator ("<Primary>q", "app.quit", null);
var menu = new Menu ();
var section = new Menu ();
menu.append_section (null, section);
- section.append (_("_New Game"), "app.new-game");
+ section.append (_("_New Game"), "win.new-game");
section = new Menu ();
menu.append_section (null, section);
section.append (_("_Help"), "app.help");
@@ -52,13 +60,28 @@ public class LightsOff : Gtk.Application
settings = new Settings ("org.gnome.lightsoff");
window = new Gtk.ApplicationWindow (this);
+ window.add_action_entries (window_actions, this);
window.icon_name = "lightsoff";
window.resizable = false;
- var headerbar = new Gtk.HeaderBar ();
+ var left_button = new Gtk.Button.from_icon_name ("go-previous-symbolic", Gtk.IconSize.BUTTON);
+ left_button.valign = Gtk.Align.CENTER;
+ left_button.action_name = "win.previous-level";
+ left_button.set_tooltip_text (_("Return to the previous level"));
+ left_button.show ();
+
+ var right_button = new Gtk.Button.from_icon_name ("go-next-symbolic", Gtk.IconSize.BUTTON);
+ right_button.valign = Gtk.Align.CENTER;
+ right_button.action_name = "win.next-level";
+ right_button.set_tooltip_text (_("Proceed to the next level"));
+ right_button.show ();
+
+ headerbar = new Gtk.HeaderBar ();
headerbar.show_close_button = true;
- headerbar.set_title (_("Lights Off"));
+ headerbar.pack_start (left_button);
+ headerbar.pack_end (right_button);
headerbar.show ();
+ level_changed_cb (settings.get_int ("level"));
window.set_titlebar (headerbar);
var clutter_embed = new GtkClutter.Embed ();
@@ -77,10 +100,31 @@ public class LightsOff : Gtk.Application
stage.set_size (game_view.width, game_view.height);
clutter_embed.set_size_request ((int) stage.width, (int) stage.height);
}
-
+
+ private void update_title (int level)
+ {
+ /* The title of the window, %d is the level number */
+ headerbar.title = _("Level %d".printf (level));
+ /* Subtitle of the window when playing level one. */
+ headerbar.subtitle = level == 1 ? _("Turn off all the lights!") : null;
+ }
+
+ private void previous_level_cb ()
+ {
+ game_view.swap_board (-1);
+ }
+
+ private void next_level_cb ()
+ {
+ game_view.swap_board (1);
+ }
+
private void level_changed_cb (int level)
{
- settings.set_int ("level", level);
+ ((SimpleAction) (window.lookup_action ("previous-level"))).set_enabled (level > 1);
+ update_title (level);
+ if (level != settings.get_int ("level"))
+ settings.set_int ("level", level);
}
private bool key_release_event_cb (Clutter.Actor actor, Clutter.KeyEvent event)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]