svn-id: r13701
This commit is contained in:
Paweł Kołodziejski 2004-05-01 09:37:24 +00:00
parent 4265979a6a
commit 6b39b875fc
3 changed files with 93 additions and 215 deletions

View file

@ -20,21 +20,13 @@
* $Header$ * $Header$
* *
*/ */
/*
Description:
Game interface module // Game interface module
Notes:
*/
#include "reinherit.h" #include "reinherit.h"
#include "yslib.h" #include "yslib.h"
/*
* Uses the following modules:
\*--------------------------------------------------------------------------*/
#include "game_mod.h" #include "game_mod.h"
#include "cvar_mod.h" #include "cvar_mod.h"
#include "actor_mod.h" #include "actor_mod.h"
@ -47,9 +39,6 @@
#include "script_mod.h" #include "script_mod.h"
#include "sprite_mod.h" #include "sprite_mod.h"
/*
* Begin module
\*--------------------------------------------------------------------------*/
#include "interface_mod.h" #include "interface_mod.h"
#include "interface.h" #include "interface.h"
@ -88,7 +77,7 @@ static R_INTERFACE_DESC ITE_interface = {
static R_INTERFACE_BUTTON ITE_c_buttons[] = { static R_INTERFACE_BUTTON ITE_c_buttons[] = {
{5, 4, 46, 47, "Portrait", 0, 0, BUTTON_NONE, 0}, {5, 4, 46, 47, "Portrait", 0, 0, BUTTON_NONE, 0},
/* "Walk To" and "Talk To" share button sprites */ // "Walk To" and "Talk To" share button sprites
{52, 4, 109, 14, "Walk To", 1, 2, BUTTON_VERB, I_VERB_WALKTO}, {52, 4, 109, 14, "Walk To", 1, 2, BUTTON_VERB, I_VERB_WALKTO},
{52, 15, 109, 25, "Look At", 3, 4, BUTTON_VERB, I_VERB_LOOKAT}, {52, 15, 109, 25, "Look At", 3, 4, BUTTON_VERB, I_VERB_LOOKAT},
{52, 26, 109, 36, "Pick Up", 5, 6, BUTTON_VERB, I_VERB_PICKUP}, {52, 26, 109, 36, "Pick Up", 5, 6, BUTTON_VERB, I_VERB_PICKUP},
@ -161,58 +150,47 @@ int INTERFACE_Init(void) {
IfModule.i_thread = STHREAD_Create(); IfModule.i_thread = STHREAD_Create();
if (IfModule.i_thread == NULL) { if (IfModule.i_thread == NULL) {
R_printf(R_STDERR, R_printf(R_STDERR, "Error creating script thread for game interface module.\n");
"Error creating script thread for game interface "
"module.\n");
return R_FAILURE; return R_FAILURE;
} }
/* Load interface module resource file context */ // Load interface module resource file context
result = GAME_GetFileContext(&IfModule.i_file_ctxt, result = GAME_GetFileContext(&IfModule.i_file_ctxt, R_GAME_RESOURCEFILE, 0);
R_GAME_RESOURCEFILE, 0);
if (result != R_SUCCESS) { if (result != R_SUCCESS) {
return R_FAILURE; return R_FAILURE;
} }
/* Initialize interface data by game type */ // Initialize interface data by game type
game_type = GAME_GetGameType(); game_type = GAME_GetGameType();
if (game_type == R_GAMETYPE_ITE) { if (game_type == R_GAMETYPE_ITE) {
/* Load Inherit the Earth interface desc */ // Load Inherit the Earth interface desc
IfModule.c_panel.buttons = ITE_c_buttons; IfModule.c_panel.buttons = ITE_c_buttons;
IfModule.c_panel.nbuttons = ARRAYSIZE(ITE_c_buttons); IfModule.c_panel.nbuttons = ARRAYSIZE(ITE_c_buttons);
IfModule.i_desc = ITE_interface; IfModule.i_desc = ITE_interface;
} else if (game_type == R_GAMETYPE_IHNM) { } else if (game_type == R_GAMETYPE_IHNM) {
/* Load I Have No Mouth interface desc */ // Load I Have No Mouth interface desc
IfModule.c_panel.buttons = IHNM_c_buttons; IfModule.c_panel.buttons = IHNM_c_buttons;
IfModule.c_panel.nbuttons = ARRAYSIZE(IHNM_c_buttons); IfModule.c_panel.nbuttons = ARRAYSIZE(IHNM_c_buttons);
IfModule.i_desc = IHNM_interface; IfModule.i_desc = IHNM_interface;
} else { } else {
return R_FAILURE; return R_FAILURE;
} }
/* Load interface resources */ // Load interface resources
GAME_GetResourceInfo(&g_resdesc); GAME_GetResourceInfo(&g_resdesc);
/* Load command panel resource */ // Load command panel resource
result = RSC_LoadResource(IfModule.i_file_ctxt, result = RSC_LoadResource(IfModule.i_file_ctxt, g_resdesc.command_panel_rn,
g_resdesc.command_panel_rn, &IfModule.c_panel.res, &IfModule.c_panel.res_len);
&IfModule.c_panel.res, &IfModule.c_panel.res_len);
if (result != R_SUCCESS) { if (result != R_SUCCESS) {
return R_FAILURE; return R_FAILURE;
} }
/* Load dialogue panel resource */ // Load dialogue panel resource
result = RSC_LoadResource(IfModule.i_file_ctxt, result = RSC_LoadResource(IfModule.i_file_ctxt, g_resdesc.dialogue_panel_rn,
g_resdesc.dialogue_panel_rn, &IfModule.d_panel.res, &IfModule.d_panel.res_len);
&IfModule.d_panel.res, &IfModule.d_panel.res_len);
if (result != R_SUCCESS) { if (result != R_SUCCESS) {
return R_FAILURE; return R_FAILURE;
} }
@ -220,17 +198,12 @@ int INTERFACE_Init(void) {
SPRITE_LoadList(ITE_DEFAULT_PORTRAITS, &IfModule.def_portraits); SPRITE_LoadList(ITE_DEFAULT_PORTRAITS, &IfModule.def_portraits);
IMG_DecodeBGImage(IfModule.c_panel.res, IMG_DecodeBGImage(IfModule.c_panel.res, IfModule.c_panel.res_len, &IfModule.c_panel.img,
IfModule.c_panel.res_len, &IfModule.c_panel.img_len, &IfModule.c_panel.img_w, &IfModule.c_panel.img_h);
&IfModule.c_panel.img,
&IfModule.c_panel.img_len,
&IfModule.c_panel.img_w, &IfModule.c_panel.img_h);
IMG_DecodeBGImage(IfModule.d_panel.res, IMG_DecodeBGImage(IfModule.d_panel.res, IfModule.d_panel.res_len,
IfModule.d_panel.res_len, &IfModule.d_panel.img, &IfModule.d_panel.img_len,
&IfModule.d_panel.img, &IfModule.d_panel.img_w, &IfModule.d_panel.img_h);
&IfModule.d_panel.img_len,
&IfModule.d_panel.img_w, &IfModule.d_panel.img_h);
IfModule.c_panel.x = 0; IfModule.c_panel.x = 0;
IfModule.c_panel.y = 149; IfModule.c_panel.y = 149;
@ -248,14 +221,14 @@ int INTERFACE_Init(void) {
return R_SUCCESS; return R_SUCCESS;
} }
int INTERFACE_Activate(void) { int INTERFACE_Activate() {
IfModule.active = 1; IfModule.active = 1;
INTERFACE_Draw(); INTERFACE_Draw();
return R_SUCCESS; return R_SUCCESS;
} }
int INTERFACE_Deactivate(void) { int INTERFACE_Deactivate() {
IfModule.active = 0; IfModule.active = 0;
return R_SUCCESS; return R_SUCCESS;
@ -269,9 +242,8 @@ int INTERFACE_SetStatusText(const char *new_txt) {
return R_SUCCESS; return R_SUCCESS;
} }
int INTERFACE_Draw(void) { int INTERFACE_Draw() {
R_GAME_DISPLAYINFO g_di; R_GAME_DISPLAYINFO g_di;
R_SURFACE *back_buf; R_SURFACE *back_buf;
int xbase; int xbase;
@ -288,10 +260,10 @@ int INTERFACE_Draw(void) {
return R_SUCCESS; return R_SUCCESS;
} }
/* Get game display info */ // Get game display info
GAME_GetDisplayInfo(&g_di); GAME_GetDisplayInfo(&g_di);
/* Erase background of status bar */ // Erase background of status bar
rect.left = 0; rect.left = 0;
rect.top = IfModule.i_desc.status_h - 1; rect.top = IfModule.i_desc.status_h - 1;
@ -300,7 +272,7 @@ int INTERFACE_Draw(void) {
GFX_DrawRect(back_buf, &rect, IfModule.i_desc.status_bgcol); GFX_DrawRect(back_buf, &rect, IfModule.i_desc.status_bgcol);
/* Draw command panel background */ // Draw command panel background
if (IfModule.panel_mode == PANEL_COMMAND) { if (IfModule.panel_mode == PANEL_COMMAND) {
xbase = IfModule.c_panel.x; xbase = IfModule.c_panel.x;
ybase = IfModule.c_panel.y; ybase = IfModule.c_panel.y;
@ -308,10 +280,8 @@ int INTERFACE_Draw(void) {
origin.x = 0; origin.x = 0;
origin.y = g_di.logical_h - IfModule.c_panel.img_h; origin.y = g_di.logical_h - IfModule.c_panel.img_h;
GFX_BufToSurface(back_buf, GFX_BufToSurface(back_buf, IfModule.c_panel.img, IfModule.c_panel.img_w,
IfModule.c_panel.img, IfModule.c_panel.img_h, NULL, &origin);
IfModule.c_panel.img_w,
IfModule.c_panel.img_h, NULL, &origin);
} else { } else {
xbase = IfModule.d_panel.x; xbase = IfModule.d_panel.x;
ybase = IfModule.d_panel.y; ybase = IfModule.d_panel.y;
@ -319,19 +289,15 @@ int INTERFACE_Draw(void) {
origin.x = 0; origin.x = 0;
origin.y = g_di.logical_h - IfModule.c_panel.img_h; origin.y = g_di.logical_h - IfModule.c_panel.img_h;
GFX_BufToSurface(back_buf, GFX_BufToSurface(back_buf, IfModule.d_panel.img, IfModule.d_panel.img_w,
IfModule.d_panel.img, IfModule.d_panel.img_h, NULL, &origin);
IfModule.d_panel.img_w,
IfModule.d_panel.img_h, NULL, &origin);
} }
/* Draw character portrait */ // Draw character portrait
lportrait_x = xbase + IfModule.i_desc.lportrait_x; lportrait_x = xbase + IfModule.i_desc.lportrait_x;
lportrait_y = ybase + IfModule.i_desc.lportrait_y; lportrait_y = ybase + IfModule.i_desc.lportrait_y;
SPRITE_Draw(back_buf, SPRITE_Draw(back_buf, IfModule.def_portraits, IfModule.active_portrait, lportrait_x, lportrait_y);
IfModule.def_portraits,
IfModule.active_portrait, lportrait_x, lportrait_y);
return R_SUCCESS; return R_SUCCESS;
} }
@ -354,12 +320,12 @@ int INTERFACE_Update(R_POINT *imouse_pt, int update_flag) {
back_buf = SYSGFX_GetBackBuffer(); back_buf = SYSGFX_GetBackBuffer();
/* Get game display info */ // Get game display info
GAME_GetDisplayInfo(&g_di); GAME_GetDisplayInfo(&g_di);
/* Update playfield space ( only if cursor is inside ) */ // Update playfield space ( only if cursor is inside )
if (imouse_y < g_di.scene_h) { if (imouse_y < g_di.scene_h) {
/* Mouse is in playfield space */ // Mouse is in playfield space
if (update_flag == UPDATE_MOUSEMOVE) { if (update_flag == UPDATE_MOUSEMOVE) {
HandlePlayfieldUpdate(back_buf, imouse_pt); HandlePlayfieldUpdate(back_buf, imouse_pt);
} else if (update_flag == UPDATE_MOUSECLICK) { } else if (update_flag == UPDATE_MOUSECLICK) {
@ -367,7 +333,7 @@ int INTERFACE_Update(R_POINT *imouse_pt, int update_flag) {
} }
} }
/* Update command space */ // Update command space
if (update_flag == UPDATE_MOUSEMOVE) { if (update_flag == UPDATE_MOUSEMOVE) {
HandleCommandUpdate(back_buf, imouse_pt); HandleCommandUpdate(back_buf, imouse_pt);
} else if (update_flag == UPDATE_MOUSECLICK) { } else if (update_flag == UPDATE_MOUSECLICK) {
@ -385,10 +351,10 @@ int DrawStatusBar(R_SURFACE *ds) {
int string_w; int string_w;
/* Get game display info */ // Get game display info
GAME_GetDisplayInfo(&g_di); GAME_GetDisplayInfo(&g_di);
/* Erase background of status bar */ // Erase background of status bar
rect.left = 0; rect.left = 0;
rect.top = IfModule.i_desc.status_y; rect.top = IfModule.i_desc.status_y;
rect.right = g_di.logical_w - 1; rect.right = g_di.logical_w - 1;
@ -396,19 +362,12 @@ int DrawStatusBar(R_SURFACE *ds) {
GFX_DrawRect(ds, &rect, IfModule.i_desc.status_bgcol); GFX_DrawRect(ds, &rect, IfModule.i_desc.status_bgcol);
string_w = FONT_GetStringWidth(SMALL_FONT_ID, string_w = FONT_GetStringWidth(SMALL_FONT_ID, IfModule.status_txt, 0, 0);
IfModule.status_txt, 0, 0);
FONT_Draw(SMALL_FONT_ID, FONT_Draw(SMALL_FONT_ID, ds, IfModule.status_txt, 0, (IfModule.i_desc.status_w / 2) - (string_w / 2),
ds, IfModule.i_desc.status_y + IfModule.i_desc.status_txt_y, IfModule.i_desc.status_txt_col, 0, 0);
IfModule.status_txt,
0,
(IfModule.i_desc.status_w / 2) - (string_w / 2),
IfModule.i_desc.status_y + IfModule.i_desc.status_txt_y,
IfModule.i_desc.status_txt_col, 0, 0);
return R_SUCCESS; return R_SUCCESS;
} }
int HandleCommandClick(R_SURFACE *ds, R_POINT *imouse_pt) { int HandleCommandClick(R_SURFACE *ds, R_POINT *imouse_pt) {
@ -426,7 +385,7 @@ int HandleCommandClick(R_SURFACE *ds, R_POINT *imouse_pt) {
hit_button = INTERFACE_HitTest(imouse_pt, &ibutton_num); hit_button = INTERFACE_HitTest(imouse_pt, &ibutton_num);
if (hit_button != R_SUCCESS) { if (hit_button != R_SUCCESS) {
/* Clicking somewhere other than a button doesn't do anything */ // Clicking somewhere other than a button doesn't do anything
return R_SUCCESS; return R_SUCCESS;
} }
@ -439,36 +398,23 @@ int HandleCommandClick(R_SURFACE *ds, R_POINT *imouse_pt) {
IfModule.c_panel.set_button = set_button; IfModule.c_panel.set_button = set_button;
if (IfModule.c_panel.buttons[set_button].flags & BUTTON_VERB) { if (IfModule.c_panel.buttons[set_button].flags & BUTTON_VERB) {
IfModule.active_verb = IfModule.active_verb = IfModule.c_panel.buttons[ibutton_num].data;
IfModule.c_panel.buttons[ibutton_num].data;
} }
if (IfModule.c_panel.buttons[set_button].flags & BUTTON_BITMAP) { if (IfModule.c_panel.buttons[set_button].flags & BUTTON_BITMAP) {
button_x = button_x = x_base + IfModule.c_panel.buttons[set_button].x1;
x_base + IfModule.c_panel.buttons[set_button].x1; button_y = y_base + IfModule.c_panel.buttons[set_button].y1;
button_y =
y_base + IfModule.c_panel.buttons[set_button].y1;
SPRITE_Draw(ds, SPRITE_Draw(ds, IfModule.c_panel.sprites, IfModule.c_panel.buttons[set_button].
IfModule.c_panel.sprites, active_sprite - 1, button_x, button_y);
IfModule.c_panel.buttons[set_button].
active_sprite - 1, button_x, button_y);
} }
if (IfModule.c_panel.buttons[old_set_button]. if (IfModule.c_panel.buttons[old_set_button].flags & BUTTON_BITMAP) {
flags & BUTTON_BITMAP) { button_x = x_base + IfModule.c_panel.buttons[old_set_button].x1;
button_y = y_base + IfModule.c_panel.buttons[old_set_button].y1;
button_x = SPRITE_Draw(ds, IfModule.c_panel.sprites, IfModule.c_panel.buttons[old_set_button].
x_base + inactive_sprite - 1, button_x, button_y);
IfModule.c_panel.buttons[old_set_button].x1;
button_y =
y_base +
IfModule.c_panel.buttons[old_set_button].y1;
SPRITE_Draw(ds,
IfModule.c_panel.sprites,
IfModule.c_panel.buttons[old_set_button].
inactive_sprite - 1, button_x, button_y);
} }
} }
@ -487,15 +433,13 @@ int HandleCommandUpdate(R_SURFACE *ds, R_POINT *imouse_pt) {
int string_w = 0; int string_w = 0;
int color; int color;
int i; int i;
hit_button = INTERFACE_HitTest(imouse_pt, &ibutton_num); hit_button = INTERFACE_HitTest(imouse_pt, &ibutton_num);
if (hit_button == R_SUCCESS) { if (hit_button == R_SUCCESS) {
/* Hovering over a command panel button */ // Hovering over a command panel button
INTERFACE_SetStatusText(I_VerbData[IfModule.active_verb]. INTERFACE_SetStatusText(I_VerbData[IfModule.active_verb].verb_str);
verb_str);
} }
for (i = 0; i < IfModule.c_panel.nbuttons; i++) { for (i = 0; i < IfModule.c_panel.nbuttons; i++) {
@ -503,13 +447,11 @@ int HandleCommandUpdate(R_SURFACE *ds, R_POINT *imouse_pt) {
continue; continue;
} }
button_w = IfModule.c_panel.buttons[i].x2 - button_w = IfModule.c_panel.buttons[i].x2 - IfModule.c_panel.buttons[i].x1;
IfModule.c_panel.buttons[i].x1;
verb_idx = IfModule.c_panel.buttons[i].data; verb_idx = IfModule.c_panel.buttons[i].data;
string_w = FONT_GetStringWidth(SMALL_FONT_ID, string_w = FONT_GetStringWidth(SMALL_FONT_ID, I_VerbData[verb_idx].verb_str, 0, 0);
I_VerbData[verb_idx].verb_str, 0, 0);
if (i == hit_button) { if (i == hit_button) {
color = IfModule.i_desc.cmd_txt_hilitecol; color = IfModule.i_desc.cmd_txt_hilitecol;
@ -520,21 +462,13 @@ int HandleCommandUpdate(R_SURFACE *ds, R_POINT *imouse_pt) {
button_x = IfModule.c_panel.x + IfModule.c_panel.buttons[i].x1; button_x = IfModule.c_panel.x + IfModule.c_panel.buttons[i].x1;
button_y = IfModule.c_panel.y + IfModule.c_panel.buttons[i].y1; button_y = IfModule.c_panel.y + IfModule.c_panel.buttons[i].y1;
FONT_Draw(SMALL_FONT_ID, FONT_Draw(SMALL_FONT_ID, ds, I_VerbData[verb_idx].verb_str, 0,
ds, button_x + ((button_w / 2) - (string_w / 2)), button_y + 1,
I_VerbData[verb_idx].verb_str, color, IfModule.i_desc.cmd_txt_shadowcol, FONT_SHADOW);
0,
button_x + ((button_w / 2) - (string_w / 2)),
button_y + 1,
color, IfModule.i_desc.cmd_txt_shadowcol, FONT_SHADOW);
if ((i == IfModule.c_panel.set_button) && if ((i == IfModule.c_panel.set_button) && (IfModule.c_panel.buttons[i].flags & BUTTON_BITMAP)) {
(IfModule.c_panel.buttons[i].flags & BUTTON_BITMAP)) { SPRITE_Draw(ds, IfModule.c_panel.sprites, IfModule.c_panel.buttons[i].active_sprite - 1,
button_x, button_y);
SPRITE_Draw(ds,
IfModule.c_panel.sprites,
IfModule.c_panel.buttons[i].active_sprite - 1,
button_x, button_y);
} }
} }
@ -552,32 +486,29 @@ int HandlePlayfieldClick(R_SURFACE *ds, R_POINT *imouse_pt) {
hit_object = OBJECTMAP_HitTest(imouse_pt, &object_num); hit_object = OBJECTMAP_HitTest(imouse_pt, &object_num);
if (hit_object != R_SUCCESS) { if (hit_object != R_SUCCESS) {
/* Player clicked on empty spot - walk here regardless of verb */ // Player clicked on empty spot - walk here regardless of verb
ACTOR_StoA(&iactor_pt, imouse_pt); ACTOR_StoA(&iactor_pt, imouse_pt);
ACTOR_WalkTo(0, &iactor_pt, 0, NULL); ACTOR_WalkTo(0, &iactor_pt, 0, NULL);
return R_SUCCESS; return R_SUCCESS;
} }
if (OBJECTMAP_GetFlags(object_num, &object_flags) != R_SUCCESS) { if (OBJECTMAP_GetFlags(object_num, &object_flags) != R_SUCCESS) {
CON_Print("Invalid object number: %d\n", object_num); CON_Print("Invalid object number: %d\n", object_num);
return R_FAILURE; return R_FAILURE;
} }
if (object_flags & R_OBJECT_NORMAL) { if (object_flags & R_OBJECT_NORMAL) {
if (OBJECTMAP_GetEPNum(object_num, &script_num) == R_SUCCESS) { if (OBJECTMAP_GetEPNum(object_num, &script_num) == R_SUCCESS) {
/* Set active verb in script module */ // Set active verb in script module
SDATA_PutWord(4, 4, SDATA_PutWord(4, 4, I_VerbData[IfModule.active_verb].s_verb);
I_VerbData[IfModule.active_verb].s_verb);
/* Execute object script if present */ // Execute object script if present
if (script_num != 0) { if (script_num != 0) {
STHREAD_Execute(IfModule.i_thread, script_num); STHREAD_Execute(IfModule.i_thread, script_num);
} }
} }
} else { } else {
/* Not a normal scene object - walk to it as if it weren't there */ // Not a normal scene object - walk to it as if it weren't there
ACTOR_StoA(&iactor_pt, imouse_pt); ACTOR_StoA(&iactor_pt, imouse_pt);
ACTOR_WalkTo(0, &iactor_pt, 0, NULL); ACTOR_WalkTo(0, &iactor_pt, 0, NULL);
} }
@ -599,33 +530,25 @@ int HandlePlayfieldUpdate(R_SURFACE *ds, R_POINT *imouse_pt) {
hit_object = OBJECTMAP_HitTest(imouse_pt, &object_num); hit_object = OBJECTMAP_HitTest(imouse_pt, &object_num);
if (hit_object != R_SUCCESS) { if (hit_object != R_SUCCESS) {
/* Cursor over nothing - just display current verb */ // Cursor over nothing - just display current verb
INTERFACE_SetStatusText(I_VerbData[IfModule.active_verb]. INTERFACE_SetStatusText(I_VerbData[IfModule.active_verb].verb_str);
verb_str);
return R_SUCCESS; return R_SUCCESS;
} }
if (OBJECTMAP_GetFlags(object_num, &object_flags) != R_SUCCESS) { if (OBJECTMAP_GetFlags(object_num, &object_flags) != R_SUCCESS) {
CON_Print("Invalid object number: %d\n", object_num); CON_Print("Invalid object number: %d\n", object_num);
return R_FAILURE; return R_FAILURE;
} }
OBJECTMAP_GetName(object_num, &object_name); OBJECTMAP_GetName(object_num, &object_name);
if (object_flags & R_OBJECT_NORMAL) { if (object_flags & R_OBJECT_NORMAL) {
/* Normal scene object - display as subject of verb */ // Normal scene object - display as subject of verb
snprintf(new_status, snprintf(new_status, R_STATUS_TEXT_LEN, "%s %s", I_VerbData[IfModule.active_verb].verb_str, object_name);
R_STATUS_TEXT_LEN,
"%s %s",
I_VerbData[IfModule.active_verb].verb_str, object_name);
} else { } else {
/* Not normal scene object - override verb as we can only // Not normal scene object - override verb as we can only
* walk to this object */ // walk to this object
snprintf(new_status, snprintf(new_status, R_STATUS_TEXT_LEN, "%s %s", I_VerbData[I_VERB_WALKTO].verb_str, object_name);
R_STATUS_TEXT_LEN,
"%s %s", I_VerbData[I_VERB_WALKTO].verb_str, object_name);
} }
INTERFACE_SetStatusText(new_status); INTERFACE_SetStatusText(new_status);
@ -649,13 +572,9 @@ int INTERFACE_HitTest(R_POINT *imouse_pt, int *ibutton) {
ybase = IfModule.c_panel.y; ybase = IfModule.c_panel.y;
for (i = 0; i < nbuttons; i++) { for (i = 0; i < nbuttons; i++) {
if ((imouse_pt->x >= (xbase + buttons[i].x1)) && if ((imouse_pt->x >= (xbase + buttons[i].x1)) && (imouse_pt->x < (xbase + buttons[i].x2)) &&
(imouse_pt->x < (xbase + buttons[i].x2)) && (imouse_pt->y >= (ybase + buttons[i].y1)) && (imouse_pt->y < (ybase + buttons[i].y2))) {
(imouse_pt->y >= (ybase + buttons[i].y1)) &&
(imouse_pt->y < (ybase + buttons[i].y2))) {
*ibutton = i; *ibutton = i;
return R_SUCCESS; return R_SUCCESS;
} }
} }

View file

@ -20,17 +20,8 @@
* $Header$ * $Header$
* *
*/ */
/*
Description:
Game interface module private header file // Game interface module private header file
Notes:
Module dependencies:
- r_script_mod
- r_sprite_mod
*/
#ifndef SAGA_INTERFACE_H__ #ifndef SAGA_INTERFACE_H__
#define SAGA_INTERFACE_H__ #define SAGA_INTERFACE_H__
@ -43,7 +34,7 @@ namespace Saga {
#define COMMAND_DEFAULT_BUTTON 1 #define COMMAND_DEFAULT_BUTTON 1
/* Inherit the Earth interface values */ // Inherit the Earth interface values
#define ITE_STATUS_Y 137 #define ITE_STATUS_Y 137
#define ITE_STATUS_W 320 #define ITE_STATUS_W 320
#define ITE_STATUS_H 12 #define ITE_STATUS_H 12
@ -58,7 +49,7 @@ namespace Saga {
#define ITE_LPORTRAIT_X 5 #define ITE_LPORTRAIT_X 5
#define ITE_LPORTRAIT_Y 4 #define ITE_LPORTRAIT_Y 4
/* IHNMAIMS interface values */ // IHNMAIMS interface values
#define IHNM_STATUS_Y 304 #define IHNM_STATUS_Y 304
#define IHNM_STATUS_W 640 #define IHNM_STATUS_W 640
#define IHNM_STATUS_H 24 #define IHNM_STATUS_H 24
@ -74,13 +65,11 @@ namespace Saga {
#define IHNM_LPORTRAIT_Y 4 #define IHNM_LPORTRAIT_Y 4
typedef enum R_PANEL_MODES_tag { typedef enum R_PANEL_MODES_tag {
PANEL_COMMAND, PANEL_COMMAND,
PANEL_DIALOGUE PANEL_DIALOGUE
} R_PANEL_MODES; } R_PANEL_MODES;
typedef enum R_BUTTON_FLAGS_tag { typedef enum R_BUTTON_FLAGS_tag {
BUTTON_NONE = 0x0, BUTTON_NONE = 0x0,
BUTTON_LABEL = 0x01, BUTTON_LABEL = 0x01,
BUTTON_BITMAP = 0x02, BUTTON_BITMAP = 0x02,
@ -91,7 +80,6 @@ typedef enum R_BUTTON_FLAGS_tag {
#define BUTTON_VERB ( BUTTON_LABEL | BUTTON_BITMAP | BUTTON_SET ) #define BUTTON_VERB ( BUTTON_LABEL | BUTTON_BITMAP | BUTTON_SET )
struct R_INTERFACE_BUTTON { struct R_INTERFACE_BUTTON {
int x1; int x1;
int y1; int y1;
int x2; int x2;
@ -101,11 +89,9 @@ struct R_INTERFACE_BUTTON {
int active_sprite; int active_sprite;
int flags; int flags;
int data; int data;
}; };
struct R_INTERFACE_PANEL { struct R_INTERFACE_PANEL {
byte *res; byte *res;
size_t res_len; size_t res_len;
int x; int x;
@ -118,53 +104,39 @@ struct R_INTERFACE_PANEL {
int nbuttons; int nbuttons;
R_INTERFACE_BUTTON *buttons; R_INTERFACE_BUTTON *buttons;
R_SPRITELIST *sprites; R_SPRITELIST *sprites;
}; };
struct R_INTERFACE_DESC { struct R_INTERFACE_DESC {
int status_y; int status_y;
int status_w; int status_w;
int status_h; int status_h;
int status_txt_y; int status_txt_y;
int status_txt_col; int status_txt_col;
int status_bgcol; int status_bgcol;
int cmd_txt_col; int cmd_txt_col;
int cmd_txt_shadowcol; int cmd_txt_shadowcol;
int cmd_txt_hilitecol; int cmd_txt_hilitecol;
int cmd_defaultbutton; int cmd_defaultbutton;
int lportrait_x; int lportrait_x;
int lportrait_y; int lportrait_y;
}; };
struct R_INTERFACE_MODULE { struct R_INTERFACE_MODULE {
int init; int init;
int active; int active;
R_RSCFILE_CONTEXT *i_file_ctxt; R_RSCFILE_CONTEXT *i_file_ctxt;
R_INTERFACE_DESC i_desc; R_INTERFACE_DESC i_desc;
R_PANEL_MODES panel_mode; R_PANEL_MODES panel_mode;
R_INTERFACE_PANEL c_panel; R_INTERFACE_PANEL c_panel;
R_INTERFACE_PANEL d_panel; R_INTERFACE_PANEL d_panel;
char status_txt[R_STATUS_TEXT_LEN]; char status_txt[R_STATUS_TEXT_LEN];
int active_portrait; int active_portrait;
R_SPRITELIST *def_portraits; R_SPRITELIST *def_portraits;
int active_verb; int active_verb;
R_SCRIPT_THREAD *i_thread; R_SCRIPT_THREAD *i_thread;
}; };
enum INTERFACE_VERBS { enum INTERFACE_VERBS {
I_VERB_WALKTO, I_VERB_WALKTO,
I_VERB_LOOKAT, I_VERB_LOOKAT,
I_VERB_PICKUP, I_VERB_PICKUP,
@ -176,21 +148,18 @@ enum INTERFACE_VERBS {
}; };
struct R_VERB_DATA { struct R_VERB_DATA {
int i_verb; int i_verb;
const char *verb_cvar; const char *verb_cvar;
char verb_str[R_VERB_STRLIMIT]; char verb_str[R_VERB_STRLIMIT];
int s_verb; int s_verb;
}; };
int INTERFACE_HitTest(R_POINT * imouse_pt, int *ibutton); int INTERFACE_HitTest(R_POINT *imouse_pt, int *ibutton);
int DrawStatusBar(R_SURFACE *ds);
int DrawStatusBar(R_SURFACE * ds); int HandleCommandUpdate(R_SURFACE *ds, R_POINT *imouse_pt);
int HandleCommandUpdate(R_SURFACE * ds, R_POINT * imouse_pt); int HandleCommandClick(R_SURFACE *ds, R_POINT *imouse_pt);
int HandleCommandClick(R_SURFACE * ds, R_POINT * imouse_pt); int HandlePlayfieldUpdate(R_SURFACE *ds, R_POINT *imouse_pt);
int HandlePlayfieldUpdate(R_SURFACE * ds, R_POINT * imouse_pt); int HandlePlayfieldClick(R_SURFACE *ds, R_POINT *imouse_pt);
int HandlePlayfieldClick(R_SURFACE * ds, R_POINT * imouse_pt);
} // End of namespace Saga } // End of namespace Saga

View file

@ -20,13 +20,8 @@
* $Header$ * $Header$
* *
*/ */
/*
Description:
Game interface module public header file // Game interface module public header file
Notes:
*/
#ifndef SAGA_INTERFACE_MOD_H #ifndef SAGA_INTERFACE_MOD_H
#define SAGA_INTERFACE_MOD_H #define SAGA_INTERFACE_MOD_H
@ -34,23 +29,18 @@
namespace Saga { namespace Saga {
typedef enum INTERFACE_UPDATE_FLAGS_tag { typedef enum INTERFACE_UPDATE_FLAGS_tag {
UPDATE_MOUSEMOVE = 1, UPDATE_MOUSEMOVE = 1,
UPDATE_MOUSECLICK UPDATE_MOUSECLICK
} INTERFACE_UPDATE_FLAGS; } INTERFACE_UPDATE_FLAGS;
int INTERFACE_RegisterLang(void); int INTERFACE_RegisterLang();
int INTERFACE_Init();
int INTERFACE_Init(void); int INTERFACE_Shutdown();
int INTERFACE_Shutdown(void); int INTERFACE_Activate();
int INTERFACE_Deactivate();
int INTERFACE_Activate(void);
int INTERFACE_Deactivate(void);
int INTERFACE_SetStatusText(const char *new_txt); int INTERFACE_SetStatusText(const char *new_txt);
int INTERFACE_Draw(void); int INTERFACE_Draw();
int INTERFACE_Update(R_POINT * imouse_pt, int update_flag); int INTERFACE_Update(R_POINT *imouse_pt, int update_flag);
} // End of namespace Saga } // End of namespace Saga