}
}
+void ClearPlayerMouseAction()
+{
+ local_player->mouse_action.lx = 0;
+ local_player->mouse_action.ly = 0;
+ local_player->mouse_action.button = 0;
+}
+
void ClearPlayerAction()
{
int i;
stored_player[i].action = 0;
ClearJoystickState();
+ ClearPlayerMouseAction();
+}
+
+void SetPlayerMouseAction(int mx, int my, int button)
+{
+ int lx = getLevelFromScreenX(mx);
+ int ly = getLevelFromScreenY(my);
+
+ ClearPlayerMouseAction();
+
+ if (!IN_GFX_FIELD_PLAY(mx, my) || !IN_LEV_FIELD(lx, ly))
+ return;
+
+ local_player->mouse_action.lx = lx;
+ local_player->mouse_action.ly = ly;
+ local_player->mouse_action.button = button;
}
void SleepWhileUnmapped()
break;
case GAME_MODE_PLAYING:
- if (level.game_engine_type == GAME_ENGINE_TYPE_MM && !tape.pausing)
- ClickElement(mx, my, button);
+ SetPlayerMouseAction(mx, my, button);
+
#if defined(TARGET_SDL2)
- else
- HandleFollowFinger(mx, my, button);
+ HandleFollowFinger(mx, my, button);
#endif
#ifdef DEBUG
player->effective_action = 0;
player->programmed_action = 0;
+ player->mouse_action.lx = 0;
+ player->mouse_action.ly = 0;
+ player->mouse_action.button = 0;
+
player->score = 0;
player->score_final = 0;
void GameActions_MM_Main()
{
- byte effective_action[MAX_PLAYERS];
boolean warp_mode = (tape.playing && tape.warp_forward && !tape.pausing);
- int i;
-
- for (i = 0; i < MAX_PLAYERS; i++)
- effective_action[i] = stored_player[i].effective_action;
- GameActions_MM(effective_action, warp_mode);
+ GameActions_MM(local_player->mouse_action, warp_mode);
}
void GameActions_RND_Main()
byte programmed_action; /* action forced by game itself (like moving
through doors); overrides other actions */
+ struct MouseActionInfo mouse_action; /* (used by MM engine only) */
+
int jx, jy, last_jx, last_jy;
int MovDir, MovPos, GfxDir, GfxPos;
int Frame, StepFrame;
extern void InitGameEngine_MM();
extern void InitGameActions_MM();
-extern void GameActions_MM(byte *, boolean);
+extern void GameActions_MM(struct MouseActionInfo, boolean);
extern void ClickElement(int, int, int);
laser.redraw = TRUE;
}
-void ClickElement(int mx, int my, int button)
+void ClickElement(int x, int y, int button)
{
static unsigned int click_delay = 0;
static int click_delay_value = CLICK_DELAY_SHORT;
static boolean new_button = TRUE;
int element;
- int x = (mx - SX) / TILEX, y = (my - SY) / TILEY;
/* do not rotate objects hit by the laser after the game was solved */
if (game_mm.level_solved && Hit[x][y])
if (button == MB_MIDDLEBUTTON) /* middle button has no function */
return;
- if (!IN_PIX_FIELD(mx - SX, my - SY))
+ if (!IN_LEV_FIELD(x, y))
return;
if (Feld[x][y] == EL_EMPTY)
}
}
-static void GameActions_MM_Ext(byte action[MAX_PLAYERS], boolean warp_mode)
+static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode)
{
static unsigned int action_delay = 0;
static unsigned int pacman_delay = 0;
return;
}
-void GameActions_MM(byte action[MAX_PLAYERS], boolean warp_mode)
+void GameActions_MM(struct MouseActionInfo action, boolean warp_mode)
{
- if (!button_status)
- ClickElement(0, 0, MB_NOT_PRESSED);
+ ClickElement(action.lx, action.ly, action.button);
GameActions_MM_Ext(action, warp_mode);
}
int style; /* needed for panel time/health graphics */
};
+struct MouseActionInfo
+{
+ int lx, ly;
+ int button;
+};
+
struct LevelStats
{
int played;