projects
/
rocksndiamonds.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
db81862
)
added support for gadget-like pressable menu buttons on main screen
author
Holger Schemel
<info@artsoft.org>
Sat, 7 Mar 2015 00:31:27 +0000
(
01:31
+0100)
committer
Holger Schemel
<info@artsoft.org>
Sat, 7 Mar 2015 00:32:23 +0000
(
01:32
+0100)
ChangeLog
patch
|
blob
|
history
src/screens.c
patch
|
blob
|
history
diff --git
a/ChangeLog
b/ChangeLog
index ee347ccbd58ae1f90e9711f077ae7b89e892b7c2..c38176acc1c8f5e9dd3ca48083de88efb13f0c52 100644
(file)
--- a/
ChangeLog
+++ b/
ChangeLog
@@
-1,3
+1,6
@@
+2015-03-07
+ * added support for gadget-like pressable menu buttons on main screen
+
2015-03-02
* added classic graphics, sounds and music to git repository
* added classic level sets to git repository
2015-03-02
* added classic graphics, sounds and music to git repository
* added classic level sets to git repository
diff --git
a/src/screens.c
b/src/screens.c
index 4ae7ac786e50266add635f325f26463f70dfaf15..e8e4133f76551431deb3d3527b217fa03cdb78d1 100644
(file)
--- a/
src/screens.c
+++ b/
src/screens.c
@@
-1006,8
+1006,24
@@
static void InitializeMainControls()
}
}
}
}
+static void DrawPressedGraphicThruMask(int dst_x, int dst_y,
+ int graphic, boolean pressed)
+{
+ struct GraphicInfo *g = &graphic_info[graphic];
+ Bitmap *src_bitmap;
+ int src_x, src_y;
+ int xoffset = (pressed ? g->pressed_xoffset : 0);
+ int yoffset = (pressed ? g->pressed_yoffset : 0);
+
+ getFixedGraphicSource(graphic, 0, &src_bitmap, &src_x, &src_y);
+
+ BlitBitmapMasked(src_bitmap, drawto, src_x + xoffset, src_y + yoffset,
+ g->width, g->height, dst_x, dst_y);
+}
+
static void DrawCursorAndText_Main_Ext(int nr, boolean active_text,
static void DrawCursorAndText_Main_Ext(int nr, boolean active_text,
- boolean active_input)
+ boolean active_input,
+ boolean pressed_button)
{
int i;
{
int i;
@@
-1044,7
+1060,7
@@
static void DrawCursorAndText_Main_Ext(int nr, boolean active_text,
int y = mSY + pos->y;
DrawBackgroundForGraphic(x, y, pos->width, pos->height, button_graphic);
int y = mSY + pos->y;
DrawBackgroundForGraphic(x, y, pos->width, pos->height, button_graphic);
- Draw
FixedGraphicThruMaskExt(drawto, x, y, button_graphic, 0
);
+ Draw
PressedGraphicThruMask(x, y, button_graphic, pressed_button
);
}
if (visibleTextPos(pos_text) && text != NULL)
}
if (visibleTextPos(pos_text) && text != NULL)
@@
-1076,15
+1092,17
@@
static void DrawCursorAndText_Main_Ext(int nr, boolean active_text,
}
}
}
}
-static void DrawCursorAndText_Main(int nr, boolean active_text)
+static void DrawCursorAndText_Main(int nr, boolean active_text,
+ boolean pressed_button)
{
{
- DrawCursorAndText_Main_Ext(nr, active_text, FALSE);
+ DrawCursorAndText_Main_Ext(nr, active_text, FALSE
, pressed_button
);
}
#if 0
}
#if 0
-static void DrawCursorAndText_Main_Input(int nr, boolean active_text)
+static void DrawCursorAndText_Main_Input(int nr, boolean active_text,
+ boolean pressed_button)
{
{
- DrawCursorAndText_Main_Ext(nr, active_text, TRUE);
+ DrawCursorAndText_Main_Ext(nr, active_text, TRUE
, pressed_button
);
}
#endif
}
#endif
@@
-1386,7
+1404,7
@@
void DrawMainMenuExt(int fade_mask, boolean do_fading)
InitializeMainControls();
InitializeMainControls();
- DrawCursorAndText_Main(-1, FALSE);
+ DrawCursorAndText_Main(-1, FALSE
, FALSE
);
DrawPreviewLevelInitial();
HandleMainMenu(0, 0, 0, 0, MB_MENU_INITIALIZE);
DrawPreviewLevelInitial();
HandleMainMenu(0, 0, 0, 0, MB_MENU_INITIALIZE);
@@
-1693,12
+1711,14
@@
void HandleMainMenu_SelectLevel(int step, int direction, int selected_level_nr)
void HandleMainMenu(int mx, int my, int dx, int dy, int button)
{
static int choice = MAIN_CONTROL_GAME;
void HandleMainMenu(int mx, int my, int dx, int dy, int button)
{
static int choice = MAIN_CONTROL_GAME;
+ static boolean button_pressed_last = FALSE;
+ boolean button_pressed = FALSE;
int pos = choice;
int i;
if (button == MB_MENU_INITIALIZE)
{
int pos = choice;
int i;
if (button == MB_MENU_INITIALIZE)
{
- DrawCursorAndText_Main(choice, TRUE);
+ DrawCursorAndText_Main(choice, TRUE
, FALSE
);
return;
}
return;
}
@@
-1718,6
+1738,16
@@
void HandleMainMenu(int mx, int my, int dx, int dy, int button)
break;
}
}
break;
}
}
+
+ // handle pressed/unpressed state for active/inactive menu buttons
+ // (if pos != -1, "i" contains index position corresponding to "pos")
+ if (button &&
+ pos >= MAIN_CONTROL_NAME && pos <= MAIN_CONTROL_QUIT &&
+ insideMenuPosRect(main_controls[i].pos_button, mx - mSX, my - mSY))
+ button_pressed = TRUE;
+
+ if (button_pressed != button_pressed_last)
+ DrawCursorAndText_Main(choice, TRUE, button_pressed);
}
else if (dx || dy) /* keyboard input */
{
}
else if (dx || dy) /* keyboard input */
{
@@
-1756,8
+1786,8
@@
void HandleMainMenu(int mx, int my, int dx, int dy, int button)
{
PlaySound(SND_MENU_ITEM_ACTIVATING);
{
PlaySound(SND_MENU_ITEM_ACTIVATING);
- DrawCursorAndText_Main(choice, FALSE);
- DrawCursorAndText_Main(pos, TRUE);
+ DrawCursorAndText_Main(choice, FALSE
, FALSE
);
+ DrawCursorAndText_Main(pos, TRUE
, button_pressed
);
choice = pos;
}
choice = pos;
}
@@
-1844,6
+1874,8
@@
void HandleMainMenu(int mx, int my, int dx, int dy, int button)
}
}
}
}
}
}
+
+ button_pressed_last = button_pressed;
}
}