[gnome-nibbles/arnaudb/wip/gtk4: 169/188] Make warps work.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-nibbles/arnaudb/wip/gtk4: 169/188] Make warps work.
- Date: Fri, 2 Oct 2020 15:55:22 +0000 (UTC)
commit 9ada78cb2dda5fccf775d57fffa382db13b42d82
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Tue Jun 16 16:20:05 2020 +0200
Make warps work.
src/nibbles-view.vala | 68 +++++++++------------------------------------------
1 file changed, 11 insertions(+), 57 deletions(-)
---
diff --git a/src/nibbles-view.vala b/src/nibbles-view.vala
index 005567a..02df3a0 100644
--- a/src/nibbles-view.vala
+++ b/src/nibbles-view.vala
@@ -62,43 +62,6 @@ private class NibblesView : Widget
// }
}
- private class WarpTexture: Widget
- {
-// private const float SIZE_MULTIPLIER = 2;
-
-// protected override void show ()
-// {
-// base.show ();
-
-// set_opacity (0);
-// set_scale (3.0, 3.0);
-
-// save_easing_state ();
-// set_easing_mode (Clutter.AnimationMode.EASE_OUT_CIRC);
-// set_easing_duration (GAMEDELAY * 15);
-// set_scale (1.0, 1.0);
-// set_pivot_point (0.5f, 0.5f);
-// set_opacity (0xff);
-// restore_easing_state ();
-// }
-
-// protected override void hide ()
-// {
-// save_easing_state ();
-// set_easing_mode (Clutter.AnimationMode.EASE_IN_QUAD);
-// set_easing_duration (GAMEDELAY * 15);
-// set_scale (0.4f, 0.4f);
-// set_pivot_point (0.5f, 0.5f);
-// set_opacity (0);
-// restore_easing_state ();
-// }
-
-// internal new void set_size (float width, float height)
-// {
-// base.set_size (SIZE_MULTIPLIER * width, SIZE_MULTIPLIER * height);
-// }
- }
-
internal const uint8 WIDTH = 92;
internal const uint8 HEIGHT = 66;
internal const int GAMEDELAY = 35;
@@ -118,7 +81,7 @@ private class NibblesView : Widget
private Gee.HashMap<Worm, WormView> worm_actors = new Gee.HashMap<Worm, WormView> ();
private Gee.HashMap<Bonus, Image> bonus_actors = new Gee.HashMap<Bonus, Image> ();
- private Gee.HashSet<WarpTexture> warp_actors = new Gee.HashSet<WarpTexture> ();
+ private Gee.HashSet<Image> warp_actors = new Gee.HashSet<Image> ();
private GridLayout layout;
@@ -784,32 +747,23 @@ private class NibblesView : Widget
private void warp_added_cb (uint8 x, uint8 y)
{
- var actor = new WarpTexture ();
-// try
-// {
-// actor.set_from_pixbuf (boni_pixmaps[BonusType.WARP]);
-// }
-// catch (Clutter.TextureError e)
-// {
-// error ("Nibbles failed to set texture: %s", e.message);
-// }
-// catch (Error e)
-// {
-// error ("Nibbles failed to set texture: %s", e.message);
-// }
-
-// actor.set_size (tile_size, tile_size);
-// actor.set_position ((int) x * tile_size, (int) y * tile_size);
+ var actor = new Image.from_pixbuf (boni_pixmaps [BonusType.WARP]);
+ actor.pixel_size = 2 * tile_size;
+ actor.insert_after (this, /* insert first */ null);
-// level.add_child (actor);
+ GridLayoutChild child_layout = (GridLayoutChild) layout.get_layout_child (actor);
+ child_layout.set_column (x);
+ child_layout.set_row (y);
+ child_layout.set_column_span (2);
+ child_layout.set_row_span (2);
warp_actors.add (actor);
}
private void warps_rescale (int new_tile_size)
{
-// foreach (var actor in warp_actors)
-// actor.set_size (new_tile_size, new_tile_size);
+ foreach (var actor in warp_actors)
+ actor.pixel_size = 2 * new_tile_size;
}
/*\
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]