[gnome-nibbles/arnaudb/wip/gtk4: 51/62] Make warps work.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-nibbles/arnaudb/wip/gtk4: 51/62] Make warps work.
- Date: Fri, 19 Jun 2020 14:56:19 +0000 (UTC)
commit 3cde49d280a07cff185ce87fe36cf4e12897b018
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 028071c..e32da50 100644
--- a/src/nibbles-view.vala
+++ b/src/nibbles-view.vala
@@ -60,43 +60,6 @@ private class WormView : Object
// }
}
-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 (NibblesGame.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 (NibblesGame.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);
-// }
-}
-
private class NibblesView : Widget
{
private const int MINIMUM_TILE_SIZE = 7;
@@ -114,7 +77,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;
@@ -788,32 +751,23 @@ private class NibblesView : Widget
private void warp_added_cb (int x, int 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 (x * tile_size, 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_left_attach (x);
+ child_layout.set_top_attach (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]