This commit is contained in:
Ben Lankamp
2020-06-15 21:21:45 +02:00
51 changed files with 1163 additions and 168 deletions
+2
View File
@@ -505,6 +505,7 @@ set(src_redalert
./RedAlert/SOUNDDLG.H
./RedAlert/SPECIAL.CPP
./RedAlert/SPECIAL.H
./RedAlert/NewBlit.cpp
./RedAlert/SPRITE.CPP
./RedAlert/STAGE.H
./RedAlert/STARTUP.CPP
@@ -705,6 +706,7 @@ set(src_external
./external/lua/lzio.h
)
add_definitions(-DCHEAT_KEYS -DIMGUI_IMPL_OPENGL_LOADER_GLEW -DSCENARIO_EDITOR -DWINDOWS_IGNORE_PACKING_MISMATCH -DTRUE_FALSE_DEFINED -DWIN32 -DWINDOWS -DENGLISH -D_USRDLL -DREDALERT_EXPORTS)
add_compile_options(/permissive+ /Zc:forScope- /Zp1)
+4
View File
@@ -174,6 +174,9 @@ char TeamEvent = 0; // 0 = no event, 1,2,3 = team event type
char TeamNumber = 0; // which team was selected? (1-9)
char FormationEvent = 0; // 0 = no event, 1 = formation was toggled
bool g_inMainMenu = false;
/* -----------------10/14/96 7:29PM------------------
@@ -278,6 +281,7 @@ void Main_Game(int argc, char * argv[])
#endif // !WOLAPI_INTEGRATION
}
#endif //WIN32
g_inMainMenu = false;
#ifdef SCENARIO_EDITOR
/*
+84 -30
View File
@@ -46,7 +46,7 @@
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "function.h"
#include "Image.h"
#include "defines.h" //VG 10/17/96
unsigned char * Font_Palette(int color);
@@ -98,55 +98,104 @@ void Dialog_Box(int x, int y, int w, int h)
*/
int cx = w/2;
int cy = h/2;
// jmarshall
void const * shapedata = MFCD::Retrieve("DD-BKGND.SHP");
#ifdef WIN32
CC_Draw_Shape(shapedata, 0, cx-312, cy-192, WINDOW_PARTIAL, SHAPE_WIN_REL);
CC_Draw_Shape(shapedata, 1, cx, cy-192, WINDOW_PARTIAL, SHAPE_WIN_REL);
CC_Draw_Shape(shapedata, 2, cx-312, cy, WINDOW_PARTIAL, SHAPE_WIN_REL);
CC_Draw_Shape(shapedata, 3, cx, cy, WINDOW_PARTIAL, SHAPE_WIN_REL);
#else
CC_Draw_Shape(shapedata, 0, cx-156, cy-96, WINDOW_PARTIAL, SHAPE_WIN_REL);
#endif
//#ifdef WIN32
// CC_Draw_Shape(shapedata, 0, cx-312, cy-192, WINDOW_PARTIAL, SHAPE_WIN_REL);
// CC_Draw_Shape(shapedata, 1, cx, cy-192, WINDOW_PARTIAL, SHAPE_WIN_REL);
// CC_Draw_Shape(shapedata, 2, cx-312, cy, WINDOW_PARTIAL, SHAPE_WIN_REL);
// CC_Draw_Shape(shapedata, 3, cx, cy, WINDOW_PARTIAL, SHAPE_WIN_REL);
//#else
// CC_Draw_Shape(shapedata, 0, cx-156, cy-96, WINDOW_PARTIAL, SHAPE_WIN_REL);
//#endif
GL_SetClipRect(x, y, w, h);
if (g_inMainMenu)
{
Image_t* ddbkgrnd = Image_LoadImage("ui/dd-bkgrnd/dd-bkgnd-red-0000.png");
Image_t* ddbkgrnd_1 = Image_LoadImage("ui/dd-bkgrnd/dd-bkgnd-red-0001.png");
Image_t* ddbkgrnd_2 = Image_LoadImage("ui/dd-bkgrnd/dd-bkgnd-red-0002.png");
Image_t* ddbkgrnd_3 = Image_LoadImage("ui/dd-bkgrnd/dd-bkgnd-red-0003.png");
GL_RenderImage(ddbkgrnd, x, y, ddbkgrnd->width, ddbkgrnd->height);
GL_RenderImage(ddbkgrnd_1, x + 312, y, ddbkgrnd->width, ddbkgrnd->height);
GL_RenderImage(ddbkgrnd_2, x, y + 192, ddbkgrnd->width, ddbkgrnd->height);
GL_RenderImage(ddbkgrnd_3, x + 312, y + 192, ddbkgrnd->width, ddbkgrnd->height);
}
else
{
Image_t* ddbkgrnd = Image_LoadImage("ui/dd-bkgrnd/dd-bkgnd-0000.png");
Image_t* ddbkgrnd_1 = Image_LoadImage("ui/dd-bkgrnd/dd-bkgnd-0001.png");
Image_t* ddbkgrnd_2 = Image_LoadImage("ui/dd-bkgrnd/dd-bkgnd-0002.png");
Image_t* ddbkgrnd_3 = Image_LoadImage("ui/dd-bkgrnd/dd-bkgnd-0003.png");
GL_RenderImage(ddbkgrnd, x, y, ddbkgrnd->width, ddbkgrnd->height);
GL_RenderImage(ddbkgrnd_1, x + 312, y, ddbkgrnd->width, ddbkgrnd->height);
GL_RenderImage(ddbkgrnd_2, x, y + 192, ddbkgrnd->width, ddbkgrnd->height);
GL_RenderImage(ddbkgrnd_3, x + 312, y + 192, ddbkgrnd->width, ddbkgrnd->height);
}
// jmarshall end
/*
** Draw the side strips.
*/
shapedata = MFCD::Retrieve("DD-EDGE.SHP");
//shapedata = MFCD::Retrieve("DD-EDGE.SHP");
Image_t* ddedge = Image_LoadImage("ui/dd-edge/dd-edge-0000.png");
Image_t* ddedge_1 = Image_LoadImage("ui/dd-edge/dd-edge-0001.png");
for (int yy = 0; yy < h; yy += 6) {
CC_Draw_Shape(shapedata, 0, 7*RESFACTOR, yy, WINDOW_PARTIAL, SHAPE_WIN_REL);
CC_Draw_Shape(shapedata, 1, w-((7+8)*RESFACTOR), yy, WINDOW_PARTIAL, SHAPE_WIN_REL);
//CC_Draw_Shape(shapedata, 0, 7*RESFACTOR, yy, WINDOW_PARTIAL, SHAPE_WIN_REL);
//CC_Draw_Shape(shapedata, 1, w-((7+8)*RESFACTOR), yy, WINDOW_PARTIAL, SHAPE_WIN_REL);
GL_RenderImage(ddedge, x + (7 * RESFACTOR), y + yy, ddedge->width, ddedge->height);
GL_RenderImage(ddedge_1, x + (w - ((7 + 8) * RESFACTOR)), y + yy, ddedge->width, ddedge->height);
}
/*
** Draw the border bars.
*/
shapedata = MFCD::Retrieve("DD-LEFT.SHP");
CC_Draw_Shape(shapedata, 0, 0, cy-100*RESFACTOR, WINDOW_PARTIAL, SHAPE_WIN_REL);
CC_Draw_Shape(shapedata, 0, 0, cy, WINDOW_PARTIAL, SHAPE_WIN_REL);
//shapedata = MFCD::Retrieve("DD-LEFT.SHP");
Image_t* ddleft = Image_LoadImage("ui/dd-edge/dd-left-0000.png");
GL_RenderImage(ddleft, x, y + (cy - 100 * RESFACTOR), ddleft->width * 0.5, ddleft->height * 0.5);
GL_RenderImage(ddleft, x, y + cy, ddleft->width * 0.5, ddleft->height * 0.5);
//CC_Draw_Shape(shapedata, 0, 0, cy-100*RESFACTOR, WINDOW_PARTIAL, SHAPE_WIN_REL);
//CC_Draw_Shape(shapedata, 0, 0, cy, WINDOW_PARTIAL, SHAPE_WIN_REL);
shapedata = MFCD::Retrieve("DD-RIGHT.SHP");
//shapedata = MFCD::Retrieve("DD-RIGHT.SHP");
Image_t* ddright = Image_LoadImage("ui/dd-edge/dd-right-0000.png");
int rightx = w - (7*RESFACTOR);
#ifndef WIN32
rightx--;
#endif
CC_Draw_Shape(shapedata, 0, rightx, cy-100*RESFACTOR, WINDOW_PARTIAL, SHAPE_WIN_REL);
CC_Draw_Shape(shapedata, 0, rightx, cy, WINDOW_PARTIAL, SHAPE_WIN_REL);
GL_RenderImage(ddright, x + rightx, y + (cy - 100 * RESFACTOR), ddleft->width * 0.5, ddleft->height * 0.5);
GL_RenderImage(ddright, x + rightx, y + cy, ddleft->width * 0.5, ddleft->height * 0.5);
//CC_Draw_Shape(shapedata, 0, rightx, cy-100*RESFACTOR, WINDOW_PARTIAL, SHAPE_WIN_REL);
//CC_Draw_Shape(shapedata, 0, rightx, cy, WINDOW_PARTIAL, SHAPE_WIN_REL);
shapedata = MFCD::Retrieve("DD-BOTM.SHP");
CC_Draw_Shape(shapedata, 0, cx-160*RESFACTOR, h-8*RESFACTOR, WINDOW_PARTIAL, SHAPE_WIN_REL);
CC_Draw_Shape(shapedata, 0, cx, h-8*RESFACTOR, WINDOW_PARTIAL, SHAPE_WIN_REL);
//shapedata = MFCD::Retrieve("DD-BOTM.SHP");
Image_t* ddbotm = Image_LoadImage("ui/dd-edge/dd-botm-0000.png");
GL_RenderImage(ddbotm, x + (cx - 160 * RESFACTOR), y + (h - 8 * RESFACTOR), ddbotm->width / 2, ddbotm->height / 2);
GL_RenderImage(ddbotm, x + (cx), y + (h - 8 * RESFACTOR), ddbotm->width / 2, ddbotm->height / 2);
//CC_Draw_Shape(shapedata, 0, cx-160*RESFACTOR, h-8*RESFACTOR, WINDOW_PARTIAL, SHAPE_WIN_REL);
//CC_Draw_Shape(shapedata, 0, cx, h-8*RESFACTOR, WINDOW_PARTIAL, SHAPE_WIN_REL);
shapedata = MFCD::Retrieve("DD-TOP.SHP");
CC_Draw_Shape(shapedata, 0, cx-160*RESFACTOR, 0, WINDOW_PARTIAL, SHAPE_WIN_REL);
CC_Draw_Shape(shapedata, 0, cx, 0, WINDOW_PARTIAL, SHAPE_WIN_REL);
Image_t* ddtop = Image_LoadImage("ui/dd-edge/dd-top-0000.png");
//CC_Draw_Shape(shapedata, 0, cx-160*RESFACTOR, 0, WINDOW_PARTIAL, SHAPE_WIN_REL);
//CC_Draw_Shape(shapedata, 0, cx, 0, WINDOW_PARTIAL, SHAPE_WIN_REL);
GL_RenderImage(ddtop, x + (cx - 160 * RESFACTOR), y, ddtop->width / 2, ddtop->height / 2);
GL_RenderImage(ddtop, x + (cx), y, ddtop->width / 2, ddtop->height / 2);
/*
** Draw the corner caps.
*/
shapedata = MFCD::Retrieve("DD-CRNR.SHP");
CC_Draw_Shape(shapedata, 0, 0, 0, WINDOW_PARTIAL, SHAPE_WIN_REL);
CC_Draw_Shape(shapedata, 1, w-(12*RESFACTOR-1), 0, WINDOW_PARTIAL, SHAPE_WIN_REL);
CC_Draw_Shape(shapedata, 2, 0, h-(12*RESFACTOR), WINDOW_PARTIAL, SHAPE_WIN_REL);
CC_Draw_Shape(shapedata, 3, w-(12*RESFACTOR-1), h-(12*RESFACTOR), WINDOW_PARTIAL, SHAPE_WIN_REL);
//shapedata = MFCD::Retrieve("DD-CRNR.SHP");
Image_t* ddcrnr0 = Image_LoadImage("ui/dd-edge/dd-crnr-0000.png");
Image_t* ddcrnr1 = Image_LoadImage("ui/dd-edge/dd-crnr-0001.png");
Image_t* ddcrnr2 = Image_LoadImage("ui/dd-edge/dd-crnr-0002.png");
Image_t* ddcrnr3 = Image_LoadImage("ui/dd-edge/dd-crnr-0003.png");
GL_RenderImage(ddcrnr0, x, y, 23, 24);
GL_RenderImage(ddcrnr1, x + (w - (12 * RESFACTOR - 1)), y, 23, 24);
GL_RenderImage(ddcrnr2, x, y + (h - (12 * RESFACTOR)), 23, 24);
GL_RenderImage(ddcrnr3, x + (w - (12 * RESFACTOR - 1)), y + (h - (12 * RESFACTOR)), 23, 24);
//CC_Draw_Shape(shapedata, 0, 0, 0, WINDOW_PARTIAL, SHAPE_WIN_REL);
//CC_Draw_Shape(shapedata, 1, w-(12*RESFACTOR-1), 0, WINDOW_PARTIAL, SHAPE_WIN_REL);
//CC_Draw_Shape(shapedata, 2, 0, h-(12*RESFACTOR), WINDOW_PARTIAL, SHAPE_WIN_REL);
//CC_Draw_Shape(shapedata, 3, w-(12*RESFACTOR-1), h-(12*RESFACTOR), WINDOW_PARTIAL, SHAPE_WIN_REL);
#ifdef WIN32
WWMouse->Draw_Mouse(&HidPage);
@@ -160,6 +209,8 @@ void Dialog_Box(int x, int y, int w, int h)
// Shadow_Blit(0, 0, 320, 200, HidPage, SeenPage, ((GraphicBufferClass*)Map.Shadow_Address())->Get_Buffer());
#endif
Set_Logic_Page(oldpage);
GL_ResetClipRect();
}
@@ -207,7 +258,10 @@ void Draw_Box(int x, int y, int w, int h, BoxStyleEnum up, bool filled)
BoxStyleType const &style = ButtonColors[up];
if (filled) {
LogicPage->Fill_Rect( x, y, x+w, y+h, style.Filler);
// jmarshall
//LogicPage->Fill_Rect( x, y, x+w, y+h, style.Filler);
GL_FillRect(style.Filler, x, y, w, h);
// jmarshall end
}
switch (up) {
+1 -1
View File
@@ -497,7 +497,7 @@ bool Expansion_Dialog(void)
Call_Back();
if (display) {
{
display = false;
Hide_Mouse();
+29 -1
View File
@@ -1072,7 +1072,7 @@ extern DynamicVectorClass<EventChoiceClass *> xxx2;
template <>class DynamicVectorClass<ActionChoiceClass *>;
extern DynamicVectorClass<ActionChoiceClass *> xxx3;
void WWSDL_ProcessEvents(KeyNumType& key, int& flags);
void WWSDL_ProcessEvents(KeyNumType& key, int& flags, bool presentBuffer = true);
void Device_Present(void);
/*
@@ -1152,5 +1152,33 @@ extern const int NUM_EDIT_MISSIONS;
extern void (*Imgui_Dialog_Function)(void);
/*
==================
COM_SetExtension
==================
*/
__forceinline void COM_SetExtension(char* path, int maxSize, const char* extension) {
char oldPath[2048];
char* src;
//
// if path doesn't have a .EXT, append extension
// (extension should include the .)
//
src = path + strlen(path) - 1;
while (*src != '/' && src != path) {
if (*src == '.') {
*src = 0;
break;
}
src--;
}
strcpy(oldPath, path);
sprintf(path, "%s%s", oldPath, extension);
}
extern bool g_inMainMenu;
#endif
+2 -2
View File
@@ -260,7 +260,7 @@ void GameControlsClass::Process(void)
/*
** Refresh display if needed.
*/
if (display) {
{
Hide_Mouse();
Map.Flag_To_Redraw(true);
@@ -273,7 +273,7 @@ void GameControlsClass::Process(void)
refresh = true;
}
if (refresh) {
{
Hide_Mouse();
/*
+2 -2
View File
@@ -265,7 +265,7 @@ void GameOptionsClass::Process(void)
bool process = true;
pressed = false;
while (process) {
Device_Present();
//Device_Present();
/*
** Invoke game callback.
@@ -292,7 +292,7 @@ void GameOptionsClass::Process(void)
/*
** Refresh display if needed.
*/
if (display || RedrawOptionsMenu) {
{
/*
** Redraw the map.
+1 -1
View File
@@ -658,7 +658,6 @@ bool Select_Game(bool fade)
#endif
while (process) {
/*
** Redraw the title page if needed
*/
@@ -734,6 +733,7 @@ bool Select_Game(bool fade)
#ifdef FIXIT_ANTS
AntsEnabled = false;
#endif
g_inMainMenu = true;
selection = Main_Menu(ATTRACT_MODE_TIMEOUT);
}
Call_Back();
+7 -4
View File
@@ -258,6 +258,9 @@ int LoadOptionsClass::Process(void)
bool display = true;
bool process = true;
while (process) {
if (g_inMainMenu) {
Load_Title_Screen("TITLE.PCX", NULL, NULL);
}
/*
** Invoke game callback.
@@ -285,13 +288,13 @@ int LoadOptionsClass::Process(void)
/*
** Refresh display if needed.
*/
if (display) {
{
/*
** Display the dialog box.
*/
Hide_Mouse();
if (display) {
{
Dialog_Box(d_dialog_x, d_dialog_y, d_dialog_w, d_dialog_h);
Draw_Caption(caption, d_dialog_x, d_dialog_y, d_dialog_w);
@@ -304,8 +307,8 @@ int LoadOptionsClass::Process(void)
/*
** Redraw the buttons.
*/
if (display) {
commands->Flag_List_To_Redraw();
{
commands->Draw_All(); // jmarshall draw all
}
Show_Mouse();
display = false;
+1 -1
View File
@@ -797,7 +797,7 @@ int Main_Menu(unsigned long )
break;
}
Device_Present();
//Device_Present();
}
Options.Set_Score_Volume(oldvolume, false);
+4 -6
View File
@@ -190,8 +190,6 @@ GameType Select_MPlayer_Game (void)
process = true;
pressed = false;
while (process) {
Device_Present();
#ifdef WIN32
/*
** If we have just received input focus again after running in the background then
@@ -212,9 +210,9 @@ GameType Select_MPlayer_Game (void)
//.....................................................................
// Refresh display if needed
//.....................................................................
if (display) {
{
Hide_Mouse();
if (display >= REDRAW_BACKGROUND) {
{
//...............................................................
// Refresh the backdrop
@@ -232,8 +230,8 @@ GameType Select_MPlayer_Game (void)
//..................................................................
// Redraw buttons
//..................................................................
if (display >= REDRAW_BUTTONS) {
commands->Flag_List_To_Redraw();
{
commands->Draw_All(); // jmarshall: force redraw everything.
}
Show_Mouse();
display = REDRAW_NONE;
+6 -2
View File
@@ -258,8 +258,12 @@ int WWMessageBox::Process(const char * msg, const char * b1txt, const char * b2t
process = true;
pressed = false;
while (process) {
Device_Present();
// jmarshall
// If not in game, display the title screen.
if (g_inMainMenu) {
Load_Title_Screen("TITLE.PCX", NULL, NULL);
}
// jmarshall end
#ifdef WIN32
/*
+866 -63
View File
@@ -4,91 +4,894 @@
#include "FUNCTION.H"
#include "MapScript.h"
static int Script_GiveMoney(lua_State* L) {
int cashToGive = lua_tointeger(L, -1);
PlayerPtr->Refund_Money(cashToGive);
return 1;
/***********************************************************************************************
* Script_GiveCreditsToPlayer - Gives a given player a given amount of credits *
* *
* SCRIPT INPUT: houseType (int) - The player (house) index to give credits to *
* cashToGive (int) - The amount of cold hard credits to give the player *
* *
* SCRIPT OUTPUT: void *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
* HISTORY: *
* 6/11/2020 - JM Created *
* 6/12/2020 - JJ Added player (house) index input *
*=============================================================================================*/
static int Script_GiveCreditsToPlayer(lua_State* L) {
int houseType = lua_tointeger(L, 1);
int cashToGive = lua_tointeger(L, 2);
for (int h_index = 0; h_index < Houses.Count(); h_index++) {
HouseClass* house = Houses.Ptr(h_index);
if (house->ID == houseType) {
house->Refund_Money(cashToGive);
}
}
return 1;
}
/***********************************************************************************************
* Script_NumBuildingTypeForPlayer - Returns the amount of specific buildings for a player *
* *
* SCRIPT INPUT: houseType (int) - The player (house) index to count buildings for *
* structType (int) - The structure index to count buildings for *
* *
* SCRIPT OUTPUT: result (number) - The amount of matching buildings for that player *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_NumBuildingTypeForPlayer(lua_State* L) {
int houseType = lua_tointeger(L, 1);
int structType = lua_tointeger(L, 2);
int result = 0;
for (int b_index = 0; b_index < Buildings.Count(); b_index++) {
BuildingClass* building = Buildings.Ptr(b_index);
int houseType = lua_tointeger(L, 1);
int structType = lua_tointeger(L, 2);
int result = 0;
for (int b_index = 0; b_index < Buildings.Count(); b_index++) {
BuildingClass* building = Buildings.Ptr(b_index);
if (building->Owner() == houseType) {
if (building->Class->Type == structType) {
result++;
}
}
}
if (building->Owner() == houseType) {
if (building->Class->Type == structType) {
result++;
}
}
}
lua_pushnumber(L, result);
return 1;
lua_pushnumber(L, result);
return 1;
}
static int Script_StartMissionTimer(lua_State* L) {
int ret = lua_tointeger(L, -1);
Scen.MissionTimer = Scen.MissionTimer + (ret * (TICKS_PER_MINUTE / 10));
Scen.MissionTimer.Start();
Map.Redraw_Tab();
return 1;
/***********************************************************************************************
* Script_Win - The specified player wins *
* *
* SCRIPT INPUT: houseType (int) - The player (house that wins) *
* *
* SCRIPT OUTPUT: void *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_Win(lua_State* L) {
int houseType = lua_tointeger(L, -1);
if (houseType != HOUSE_NONE) {
HouseClass* this_house = HouseClass::As_Pointer((HousesType)houseType);
if (this_house != NULL) {
if (this_house->ID == PlayerPtr->Class->House) {
PlayerPtr->Flag_To_Win();
}
else {
PlayerPtr->Flag_To_Lose();
}
bool success = this_house->Fire_Sale();
lua_pushboolean(L, int(success));
}
}
return 1;
}
static int Script_StopMissionTimer(lua_State* L) {
Scen.MissionTimer.Start();
return 1;
/***********************************************************************************************
* Script_Lose - The specified player loses *
* *
* SCRIPT INPUT: ret (int) - The waypoint index of which to reveal *
* *
* SCRIPT OUTPUT: void *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_Lose(lua_State* L) {
int houseType = lua_tointeger(L, -1);
if (houseType != HOUSE_NONE) {
HouseClass* this_house = HouseClass::As_Pointer((HousesType)houseType);
if (this_house != NULL) {
if (this_house->ID == PlayerPtr->Class->House) {
PlayerPtr->Flag_To_Lose();
}
else {
PlayerPtr->Flag_To_Win();
}
bool success = this_house->Fire_Sale();
lua_pushboolean(L, int(success));
}
}
return 1;
}
/***********************************************************************************************
* Script_BeginProduction - This will enable production to begin for the house specified *
* *
* SCRIPT INPUT: houseType (int) - The AI player (house) index to allow winning for *
* *
* SCRIPT OUTPUT: void *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_BeginProduction(lua_State* L) {
int houseType = lua_tointeger(L, -1);
if (houseType != HOUSE_NONE) {
HouseClass* this_house = HouseClass::As_Pointer((HousesType)houseType);
if (this_house != NULL) {
this_house->Begin_Production();
}
}
return 1;
}
/***********************************************************************************************
* Script_CreateTeam - Attempts to create team (as defined in map) *
* *
* SCRIPT INPUT: teamType (int) - The team index to attempt to create *
* *
* SCRIPT OUTPUT: success (bool) - Did a team get created? *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_CreateTeam(lua_State* L) {
const char* teamType = lua_tostring(L, 1);
TeamTypeClass* teamPtr = TeamTypeClass::From_Name(teamType);
if (teamPtr != NULL) {
ScenarioInit++;
bool success = false;
TeamClass* new_team = teamPtr->Create_One_Of();
if (new_team != NULL) {
success = true;
}
lua_pushboolean(L, int(success));
ScenarioInit--;
}
return 1;
}
/***********************************************************************************************
* Script_DestroyTeam - Destroy all teams of the type specified *
* *
* SCRIPT INPUT: teamType (int) - The team index to attempt to destroy *
* *
* SCRIPT OUTPUT: void *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_DestroyTeam(lua_State* L) {
const char* teamType = lua_tostring(L, 1);
TeamTypeClass* teamPtr = TeamTypeClass::From_Name(teamType);
if (teamPtr != NULL) {
teamPtr->Destroy_All_Of();
}
return 1;
}
/***********************************************************************************************
* Script_AllHunt - Force all units of specified house to go into hunt mode *
* *
* SCRIPT INPUT: houseType (int) - The AI player (house) index to allow winning for *
* *
* SCRIPT OUTPUT: void *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_AllHunt(lua_State* L) {
int houseType = lua_tointeger(L, -1);
if (houseType != HOUSE_NONE) {
HouseClass* this_house = HouseClass::As_Pointer((HousesType)houseType);
if (this_house != NULL) {
this_house->Do_All_To_Hunt();
}
}
return 1;
}
/***********************************************************************************************
* Script_Reinforcements - Attempts to create reinforcements as defined by team *
* *
* SCRIPT INPUT: teamType (int) - The team index to attempt to create *
* *
* SCRIPT OUTPUT: success (bool) - Did Do_Reinforcements return true? *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_Reinforcements(lua_State* L) {
const char* teamType = lua_tostring(L, 1);
TeamTypeClass* teamPtr = TeamTypeClass::From_Name(teamType);
if (teamPtr != NULL) {
bool success = Do_Reinforcements(teamPtr);
lua_pushboolean(L, int(success));
}
else {
lua_pushboolean(L, 0);
}
return 1;
}
/***********************************************************************************************
* Script_DropZoneFlare - Places drop down smoke at specified waypoint location *
* *
* SCRIPT INPUT: ret (int) - The waypoint index of which to drop the smoke *
* *
* SCRIPT OUTPUT: void *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_DropZoneFlare(lua_State* L) {
int ret = lua_tointeger(L, -1);
if (ret > 0 && ret < sizeof(Scen.Waypoint)) {
new AnimClass(ANIM_LZ_SMOKE, Cell_Coord(Scen.Waypoint[ret]));
}
return 1;
}
/***********************************************************************************************
* Script_FireSale - Make AI house give up, selling everything and going all in on attack *
* *
* SCRIPT INPUT: houseType (int) - The AI player (house) index to allow winning for *
* *
* SCRIPT OUTPUT: success (bool) - Did the action get performed? *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_FireSale(lua_State* L) {
int houseType = lua_tointeger(L, -1);
if (houseType != HOUSE_NONE) {
HouseClass* this_house = HouseClass::As_Pointer((HousesType)houseType);
if (this_house != NULL) {
bool success = this_house->Fire_Sale();
lua_pushboolean(L, int(success));
}
}
return 1;
}
/***********************************************************************************************
* Script_PlayMovie - Plays the given movie *
* *
* SCRIPT INPUT: ret (int) - The movie index of which to play *
* *
* SCRIPT OUTPUT: void *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_PlayMovie(lua_State* L) {
int ret = lua_tointeger(L, -1);
Play_Movie((VQType)ret);
return 1;
int ret = lua_tointeger(L, -1);
Play_Movie((VQType)ret);
return 1;
}
static int Script_Speak(lua_State* L) {
int ret = lua_tointeger(L, -1);
Speak((VoxType)ret);
return 1;
/***********************************************************************************************
* Script_TriggerText - Triggers text to display in-game *
* *
* SCRIPT INPUT: textIndex (int) - The text index to display (from tutorial.ini) *
* *
* SCRIPT OUTPUT: void *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_TriggerText(lua_State* L) {
int textIndex = lua_tointeger(L, -1);
// TODO: Implement colors / flags
// JJQUESTION: This appears right but doesn't do anything. Is text broken at the moment?
if (textIndex > 0 && textIndex < sizeof(TutorialText)) {
Session.Messages.Add_Message(NULL, textIndex, (char*)TutorialText[textIndex], PCOLOR_GREEN, TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_FULLSHADOW, Rule.MessageDelay * TICKS_PER_MINUTE);
}
return 1;
}
/***********************************************************************************************
* Script_DestroyTrigger - Reveals the entire map *
* *
* SCRIPT INPUT: ret (int) - The waypoint index of which to reveal *
* *
* SCRIPT OUTPUT: void *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_DestroyTrigger(lua_State* L) {
if (!PlayerPtr->IsVisionary) {
PlayerPtr->IsVisionary = true;
for (CELL cell = 0; cell < MAP_CELL_TOTAL; cell++) {
Map.Map_Cell(cell, PlayerPtr);
}
}
return 1;
}
/***********************************************************************************************
* Script_AutoCreate - Allows house AI to begin creating autocreate teams *
* *
* Autocreation means that instead of a teamtype being *
* manually created by a Create Team trigger action, that *
* it will be subject to the autocreate function. Each *
* computer country can have its autocreation function *
* turned on through a trigger action, after which the *
* creation of the teamtypes that have autocreation turned *
* on will be subject to being created, at the whim of the *
* autocreate function. See [TeamTypes] Section for more *
* details. *
* - The Red Alert Single Player Mission Creation Guide *
* *
* *
* SCRIPT INPUT: houseType (int) - The AI player (house) index to allow autocreate for *
* createEnables (bool, default yes) - Allow autocreate on/off *
* *
* SCRIPT OUTPUT: void *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_AutoCreate(lua_State* L) {
int houseType = 0;
bool autoCreateEnabled = true;
houseType = lua_tointeger(L, 1);
// If there is a second argument given, process it
if (lua_gettop(L) == 2) {
autoCreateEnabled = lua_toboolean(L, 2);
}
if (houseType != HOUSE_NONE) {
HouseClass* this_house = HouseClass::As_Pointer((HousesType)houseType);
if (this_house != NULL) {
// If we are enabling auto creation by the house, clear alert
if (autoCreateEnabled) {
this_house->AlertTime = 0; // TODO - don't assume successful pointer
}
// Now set the parameter
this_house->IsAlerted = autoCreateEnabled;
}
}
return 1;
}
/***********************************************************************************************
* Script_AllowWin - Allows a win *
* *
* Used when you want a specific objective *
* to be met before the mission is accomplished. In other words, if the *
* trigger with this action assigned to it hasn't been fired, but the *
* actual WIN trigger has been fired, the mission will not end until this *
* "allow win" trigger is fired. *
* *
* SCRIPT INPUT: houseType (int) - The AI player (house) index to allow winning for *
* *
* SCRIPT OUTPUT: void *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_AllowWin(lua_State* L) {
int houseType = lua_tointeger(L, -1);
if (houseType != HOUSE_NONE) {
HouseClass* this_house = HouseClass::As_Pointer((HousesType)houseType);
if (this_house != NULL) {
this_house->Blockage++;
}
}
return 1;
}
/***********************************************************************************************
* Script_RevealAll - Reveals the entire map TODO: input player *
* *
* SCRIPT INPUT: ret (int) - The waypoint index of which to reveal *
* *
* SCRIPT OUTPUT: void *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_RevealAll(lua_State* L) {
if (!PlayerPtr->IsVisionary) {
PlayerPtr->IsVisionary = true;
for (CELL cell = 0; cell < MAP_CELL_TOTAL; cell++) {
Map.Map_Cell(cell, PlayerPtr);
}
}
return 1;
}
/***********************************************************************************************
* Script_RevealCell - Reveals map around given waypoint TODO: input player *
* *
* SCRIPT INPUT: ret (int) - The waypoint index of which to reveal *
* *
* SCRIPT OUTPUT: void *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_RevealCell(lua_State* L) {
int ret = lua_tointeger(L, -1);
if (!PlayerPtr->IsVisionary) {
Map.Sight_From(Scen.Waypoint[ret], Rule.GapShroudRadius, PlayerPtr, false);
}
return 1;
}
/***********************************************************************************************
* Script_RevealZone - Reveals area of map around given waypoint TODO: input player *
* *
* Reveal all cells of the zone that the specified waypoint is located in. This can be *
* used to reveal whole islands or bodies of water *
* *
* SCRIPT INPUT: ret (int) - The waypoint index of which to reveal *
* *
* SCRIPT OUTPUT: void *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_RevealZone(lua_State* L) {
int ret = lua_tointeger(L, -1);
if (!PlayerPtr->IsVisionary) {
int zone = Map[Scen.Waypoint[ret]].Zones[MZONE_CRUSHER];
for (CELL cell = 0; cell < MAP_CELL_TOTAL; cell++) {
if (Map[cell].Zones[MZONE_CRUSHER] == zone) {
Map.Map_Cell(cell, PlayerPtr);
}
}
}
return 1;
}
/***********************************************************************************************
* Script_PlaySound - Plays the given Sound *
* *
* SCRIPT INPUT: ret (int) - The sound index of which to play *
* *
* SCRIPT OUTPUT: void *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_PlaySound(lua_State* L) {
int ret = lua_tointeger(L, -1);
Sound_Effect((VocType)ret);
return 1;
}
/***********************************************************************************************
* Script_PlayMusic - Plays the given Music score. *
* *
* Plays music score at given index. Negative numbers stop any music playing. *
* *
* SCRIPT INPUT: ret (int) - The music index of which to play *
* *
* SCRIPT OUTPUT: void *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_PlayMusic(lua_State* L) {
int ret = lua_tointeger(L, -1);
if (ret < 0) {
Theme.Stop();
}
else {
Theme.Play_Song((ThemeType)ret);
}
return 1;
}
/***********************************************************************************************
* Script_PlaySpeech - Plays the given Speech audio *
* *
* SCRIPT INPUT: ret (int) - The speech index of which to play *
* *
* SCRIPT OUTPUT: void *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_PlaySpeech(lua_State* L) {
int ret = lua_tointeger(L, -1);
Speak((VoxType)ret);
return 1;
}
/***********************************************************************************************
* Script_StartMissionTimer - Starts the in-game mission timer *
* *
* SCRIPT INPUT: ret (int) - amount of time in tenths of a minute *
* *
* SCRIPT OUTPUT: void *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_StartMissionTimer(lua_State* L) {
int ret = lua_tointeger(L, -1);
Scen.MissionTimer = Scen.MissionTimer + (ret * (TICKS_PER_MINUTE / 10));
Scen.MissionTimer.Start();
Map.Redraw_Tab();
return 1;
}
/***********************************************************************************************
* Script_StopMissionTimer - Stops the in-game mission timer *
* *
* SCRIPT INPUT: none *
* *
* SCRIPT OUTPUT: void *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_StopMissionTimer(lua_State* L) {
Scen.MissionTimer.Start();
return 1;
}
/***********************************************************************************************
* Script_SetBriefingText - Sets the text on the mission briefing screen *
* *
* SCRIPT INPUT: (char*); The input text *
* *
* SCRIPT OUTPUT: void *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_SetBriefingText(lua_State* L) {
strcpy(Scen.BriefingText, lua_tostring(L, -1));
return 1;
strcpy(Scen.BriefingText, lua_tostring(L, -1));
return 1;
}
/*
==================
MapScript::CallFunction
==================
*/
/***********************************************************************************************
* MapScript::CallFunction - Calls a given function within the current script *
* *
* INPUT: functionName - The name of the function to call *
* *
* OUTPUT: void *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
void MapScript::CallFunction(const char* functionName) {
lua_getglobal(L, functionName);
lua_pcall(L, 0, 0, 0);
lua_getglobal(L, functionName);
lua_pcall(L, 0, 0, 0);
} //BriefingText
/*
==================
MapScript::Init
==================
*/
bool MapScript::Init(const char* mapName) {
char scriptName[256];
sprintf(scriptName, "scripts/%s.script", mapName);
L = luaL_newstate();
if (luaL_loadfile(L, scriptName) || lua_pcall(L, 0, 0, 0)) {
L = NULL;
return false;
}
lua_register(L, "Play_Movie", Script_PlayMovie);
lua_register(L, "SetBriefingText", Script_SetBriefingText);
lua_register(L, "Speak", Script_Speak);
lua_register(L, "StartMissionTimer", Script_StartMissionTimer);
lua_register(L, "StopMissionTimer", Script_StopMissionTimer);
lua_register(L, "NumBuildingTypeForPlayer", Script_NumBuildingTypeForPlayer);
lua_register(L, "GiveMoney", Script_GiveMoney);
return true;
/***********************************************************************************************
* MapScript::Init -- Loads and initializes script for a given map *
* *
* This routine is called at the beginning of a mission *
* *
* INPUT: mapName - The script path *
* *
* OUTPUT: bool; did the map script load and initialize? *
* *
* WARNINGS: none *
* *
*=============================================================================================*/
bool MapScript::Init(const char* mapName) {
char scriptName[256];
sprintf(scriptName, "scripts/%s.script", mapName);
L = luaL_newstate();
if (luaL_loadfile(L, scriptName) || lua_pcall(L, 0, 0, 0)) {
L = NULL;
return false;
}
/**********************************************************************************************
* Red Alert Vanilla Actions *
*=============================================================================================*/
lua_register(L, "Win", Script_Win); // player wins!
lua_register(L, "Lose", Script_Lose); // player loses.
lua_register(L, "BeginProduction", Script_BeginProduction); // computer begins factory production.
lua_register(L, "CreateTeam", Script_CreateTeam); // computer creates a certain type of team
lua_register(L, "DestroyTeam", Script_DestroyTeam); // destroy team (comment was redacted. was something offensive originally written?)
lua_register(L, "AllHunt", Script_AllHunt); // all enemy units go into hunt mode (teams destroyed).
lua_register(L, "Reinforcements", Script_Reinforcements); // player gets reinforcements (house that gets them is determined by the Reinforcement instance)
lua_register(L, "DropZoneFlare", Script_DropZoneFlare); // Deploy drop zone smoke.
lua_register(L, "FireSale", Script_FireSale); // Sell all buildings and go on rampage.
lua_register(L, "PlayMovie", Script_PlayMovie); // Play movie (temporarily suspend game).
lua_register(L, "TriggerText", Script_TriggerText); // Triggers a text message display.
lua_register(L, "DestroyTrigger", Script_DestroyTrigger); // Destroy specified trigger.
lua_register(L, "AutoCreate", Script_AutoCreate); // Computer to autocreate teams.
// Win if captured, lose if destroyed ( function does not exist )
lua_register(L, "AllowWin", Script_AllowWin); // Allows winning if triggered.
lua_register(L, "RevealAll", Script_RevealAll); // Reveal the entire map.
lua_register(L, "RevealCell", Script_RevealCell); // Reveal map around cell #.
lua_register(L, "RevealZone", Script_RevealZone); // Reveal all of specified zone.
lua_register(L, "PlaySound", Script_PlaySound); // Play sound effect.
lua_register(L, "PlayMusic", Script_PlayMusic); // Play musical score.
lua_register(L, "PlaySpeech", Script_PlaySpeech); // Play EVA speech.
// TODO: Force trigger to activate.
lua_register(L, "StartMissionTimer", Script_StartMissionTimer); // Start mission timer.
lua_register(L, "StopMissionTimer", Script_StopMissionTimer); // Stop mission timer.
/**********************************************************************************************
* Red Alert Vanilla Events *
*=============================================================================================*/
// player enters this square
// Spied by.
// Thieved by (raided or stolen vehicle).
// player discovers this object
// House has been discovered.
// player attacks this object
// player destroys this object
// Any object event will cause the trigger.
// all house's units destroyed
// all house's buildings destroyed
// all house's units & buildings destroyed
// house reaches this many credits
// Scenario elapsed time from start.
// Pre expired mission timer.
// Number of buildings destroyed.
// Number of units destroyed.
// No factories left.
// Civilian has been evacuated.
// Specified building has been built.
// Specified unit has been built.
// Specified infantry has been built.
// Specified aircraft has been built.
// Specified team member leaves map.
// Enters same zone as waypoint 'x'.
// Crosses horizontal trigger line.
// Crosses vertical trigger line.
// If specified global has been set.
// If specified global has been cleared.
// If all fake structures are gone.
// When power drops below 100%.
// All bridges destroyed.
// Check for building existing.
/**********************************************************************************************
* Utility Functions *
*=============================================================================================*/
lua_register(L, "SetBriefingText", Script_SetBriefingText); // Sets the [text] on the mission briefing screen
lua_register(L, "GiveCreditsToPlayer", Script_GiveCreditsToPlayer); // Give [player] [credits]
lua_register(L, "NumBuildingTypeForPlayer", Script_NumBuildingTypeForPlayer); // Number of buildings of [type] for given [player]
/**********************************************************************************************
* Script Globals *
*=============================================================================================*/
lua_pushnumber(L, PlayerPtr->ID); // Local (human) player
lua_setglobal(L, "_localPlayer");
return true;
}
+52
View File
@@ -0,0 +1,52 @@
// NEWBLIT.CPP
//
#include <imgui.h>
#include "FUNCTION.H"
#include "Image.h"
extern byte backbuffer_palette[768];
extern uint8_t g_ColorXlat[16];
void GL_SetClipRect(int x, int y, int width, int height) {
ImVec2 mi(x, y);
ImVec2 ma(x + width, y + height);
ImGui::GetForegroundDrawList()->PushClipRect(mi, ma);
}
void GL_ResetClipRect(void) {
ImGui::GetForegroundDrawList()->PopClipRect();
}
void GL_RenderImage(Image_t* image, int x, int y, int width, int height) {
ImVec2 mi(x, y);
ImVec2 ma(x + width, y + height);
ImGui::GetForegroundDrawList()->AddImage((ImTextureID)image->image, mi, ma);
}
void GL_FillRect(int color, int x, int y, int width, int height) {
ImVec2 mi(x, y);
ImVec2 ma(x + width, y + height);
float r = backbuffer_palette[(color * 3) + 0] / 255.0f;
float g = backbuffer_palette[(color * 3) + 1] / 255.0f;
float b = backbuffer_palette[(color * 3) + 2] / 255.0f;
ImGui::GetForegroundDrawList()->AddRectFilled(mi, ma, ImGui::ColorConvertFloat4ToU32(ImVec4(r, g, b, 1)));
}
void GL_DrawText(int color, int x, int y, char* text) {
ImVec2 pos(x, y);
color = g_ColorXlat[color % 15];
float r = backbuffer_palette[(color * 3) + 0] / 255.0f;
float g = backbuffer_palette[(color * 3) + 1] / 255.0f;
float b = backbuffer_palette[(color * 3) + 2] / 255.0f;
ImGui::GetForegroundDrawList()->AddText(pos, ImGui::ColorConvertFloat4ToU32(ImVec4(r, g, b, 1)), text);
}
void GL_DrawLine(int color, int x, int y, int dx, int dy) {
ImVec2 pos(x, y);
ImVec2 pos2(dx, dy);
float r = backbuffer_palette[(color * 3) + 0] / 255.0f;
float g = backbuffer_palette[(color * 3) + 1] / 255.0f;
float b = backbuffer_palette[(color * 3) + 2] / 255.0f;
ImGui::GetForegroundDrawList()->AddLine(pos, pos2, ImGui::ColorConvertFloat4ToU32(ImVec4(r, g, b, 1)));
}
+10
View File
@@ -0,0 +1,10 @@
// NewBlit.h
//
struct Image_t;
void GL_RenderImage(Image_t* image, int x, int y, int width, int height);
void GL_DrawText(int color, int x, int y, char* text);
void GL_FillRect(int color, int x, int y, int width, int height);
void GL_DrawLine(int color, int x, int y, int dx, int dy);
void GL_ResetClipRect(void);
void GL_SetClipRect(int x, int y, int width, int height);
+14 -10
View File
@@ -605,7 +605,6 @@ int Com_Scenario_Dialog(bool skirmish)
oh_dear_its_a_label:
while (process) {
Device_Present();
#if(SHOW_MONO)
if (!skirmish) {
NullModem.Mono_Debug_Print(0);
@@ -671,7 +670,7 @@ oh_dear_its_a_label:
/*
...................... Refresh display if needed ......................
*/
if (display) {
{
if (housebtn.IsDropped) {
housebtn.Collapse();
display = REDRAW_BACKGROUND;
@@ -681,7 +680,7 @@ oh_dear_its_a_label:
/*
.................. Redraw backgound & dialog box ...................
*/
if (display >= REDRAW_BACKGROUND) {
{
Dialog_Box(d_dialog_x, d_dialog_y, d_dialog_w, d_dialog_h);
// init font variables
@@ -716,12 +715,15 @@ oh_dear_its_a_label:
/*..................................................................
Draw the color boxes
..................................................................*/
if (display >= REDRAW_COLORS) {
{
for (i = 0; i < MAX_MPLAYER_COLORS; i++) {
LogicPage->Fill_Rect(cbox_x[i] + 1, d_color_y + 1,
cbox_x[i] + 1 + d_color_w - 2, d_color_y + 1 + d_color_h - 2,
ColorRemaps[i].Box);
// jmarshall
//LogicPage->Fill_Rect(cbox_x[i] + 1, d_color_y + 1,
// cbox_x[i] + 1 + d_color_w - 2, d_color_y + 1 + d_color_h - 2,
// ColorRemaps[i].Box);
// (i == PCOLOR_DIALOG_BLUE) ? ColorRemaps[PCOLOR_REALLY_BLUE].Box : ColorRemaps[i].Box);
GL_FillRect(ColorRemaps[i].Box, cbox_x[i] + 1, d_color_y + 1, 1 + d_color_w - 2, 1 + d_color_h - 2);
// jmarshall end
if (i == Session.ColorIdx) {
Draw_Box(cbox_x[i], d_color_y, d_color_w, d_color_h, BOXSTYLE_DOWN, false);
@@ -744,7 +746,7 @@ oh_dear_its_a_label:
//..................................................................
// Update game parameter labels
//..................................................................
if (display >= REDRAW_PARMS) {
{
// LogicPage->Fill_Rect(d_count_x + d_count_w + 2, d_count_y, d_count_x + d_count_w + 35 * RESFACTOR, d_aiplayers_y + d_aiplayers_h+RESFACTOR, BLACK);
@@ -777,13 +779,13 @@ oh_dear_its_a_label:
/*
.......................... Redraw buttons ..........................
*/
if (display >= REDRAW_BUTTONS) {
{
commands->Flag_List_To_Redraw();
commands->Draw_All();
}
Show_Mouse();
display = REDRAW_NONE;
//display = REDRAW_NONE;
}
/*
@@ -793,6 +795,8 @@ oh_dear_its_a_label:
bool droplist_is_dropped = housebtn.IsDropped;
input = commands->Input();
Load_Title_Page(true);
/*
** Sort out the input focus between the name edit box and the message system
*/
+5 -1
View File
@@ -1609,6 +1609,8 @@ int BGMessageBox(char const * msg, int btn1, int btn2)
*/
Hide_Mouse();
Show_OldFrameBuffer(false);
PaletteClass temp;
#ifdef WIN32
char *filename = "SOVPAPER.PCX";
@@ -1709,7 +1711,7 @@ int BGMessageBox(char const * msg, int btn1, int btn2)
}
#endif
if (display) {
{
display = false;
Hide_Mouse();
@@ -1867,6 +1869,8 @@ int BGMessageBox(char const * msg, int btn1, int btn2)
GadgetClass::Set_Color_Scheme(&ColorRemaps[PCOLOR_DIALOG_BLUE]);
Show_OldFrameBuffer(true);
return(retval);
}
+3
View File
@@ -413,6 +413,7 @@ void ScoreClass::Presentation(void)
#endif
BlackPalette.Set();
Show_OldFrameBuffer(false);
void const * country4 = MFCD::Retrieve("COUNTRY4.AUD");
void const * sfx4 = MFCD::Retrieve("SFX4.AUD");
@@ -866,6 +867,8 @@ Keyboard->Clear();
#endif //FIXIT
#endif
Show_OldFrameBuffer(true);
}
+4 -2
View File
@@ -532,8 +532,10 @@ int Fetch_Difficulty(void)
while (process) {
{
// jmarshall
// redraw = false;
Load_Title_Screen("TITLE.PCX", NULL, NULL);
// jmarshall end
/*
** Draw the background of the dialog.
*/
@@ -567,7 +569,7 @@ int Fetch_Difficulty(void)
*/
Call_Back();
Device_Present();
// Device_Present();
#ifdef WIN32
/*
+2 -1
View File
@@ -286,6 +286,7 @@ int __cdecl Buffer_Print2(GraphicViewPortClass& vp, const char* string, int x, i
extern "C" LONG __cdecl Buffer_Print(void* thisptr, const char* str, int x, int y, int fcolor, int bcolor)
{
Buffer_Print2(*(GraphicViewPortClass*)thisptr, str, x, y, fcolor, bcolor);
//Buffer_Print2(*(GraphicViewPortClass*)thisptr, str, x, y, fcolor, bcolor);
GL_DrawText(fcolor, x, y, (char *)str);
return 0;
}
+12 -4
View File
@@ -136,6 +136,7 @@
#include <stdlib.h>
#include <assert.h>
#include "iconcach.h"
#include "../NEWBLIT.H"
extern unsigned char* backbuffer_data_raw;
@@ -1109,10 +1110,12 @@ inline void GraphicViewPortClass::Draw_Stamp(void const * icondata, int icon, in
*=========================================================================*/
inline VOID GraphicViewPortClass::Draw_Line(int sx, int sy, int dx, int dy, unsigned char color)
{
if (Lock()){
Buffer_Draw_Line(this, sx, sy, dx, dy, color);
}
Unlock();
//if (Lock()){
// Buffer_Draw_Line(this, sx, sy, dx, dy, color);
//}
//Unlock();
GL_DrawLine(color, sx, sy, dx, dy);
}
/***************************************************************************
@@ -1129,10 +1132,14 @@ inline VOID GraphicViewPortClass::Draw_Line(int sx, int sy, int dx, int dy, unsi
*=========================================================================*/
inline VOID GraphicViewPortClass::Fill_Rect(int sx, int sy, int dx, int dy, unsigned char color)
{
// jmarshall
// Still needed for gameplay.
if (Lock()) {
Buffer_Fill_Rect(this, sx, sy, dx, dy, color);
Unlock();
}
//GL_FillRect(color, sx, sy, dx - sx, dy - sy);
// jmarshall end
}
@@ -1287,5 +1294,6 @@ inline long BufferClass::To_Page(int x, int y, int w, int h, GraphicViewPortClas
return ( return_code );
}
void Show_OldFrameBuffer(bool show);
#endif
+1 -1
View File
@@ -240,7 +240,7 @@ void WWMouseClass::RenderMouse(void) {
return;
//ImVec2 size(current_cursor->width, current_cursor->height);
//ImGui::Image((ImTextureID)current_cursor->image, size);
// Image((ImTextureID)current_cursor->image, size);
int _my = mousey + (current_cursor->height * 0.25);
int xstart = mousex - Get_Hotspot_X();
int ystart = _my - Get_Hotspot_Y();
+35 -27
View File
@@ -61,6 +61,8 @@
#include <imgui.h>
#include <examples/imgui_impl_opengl3.h>
#include <vector>
GLuint backbuffer_texture = -1;
byte* backbuffer_data;
unsigned char* backbuffer_data_raw;
@@ -127,12 +129,14 @@ Image_t* Image_LoadImage(const char* name) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
ilDeleteImages(1, &ImageName);
ilDeleteImages(1, &ImageName);
Image_t* image = new Image_t();
strcpy(image->name, name);
image->image = texture;
image->width = Width;
image->height = Height;
loaded_images.push_back(image);
return image;
}
@@ -173,13 +177,13 @@ void ImGui_NewFrame(void) {
io.DisplaySize = ImVec2(ScreenWidth, ScreenHeight);
ImGui_ImplOpenGL3_NewFrame();
ImGui::NewFrame();
ImGui::NewFrame(show_oldframebuffer);
ImGui_ImplSDL2_NewFrame(game_window);
}
void Device_Present(void)
{
void Device_Present(void) {
// Rasterize the palette.
for (int i = 0; i < ScreenWidth * ScreenHeight; i++) {
backbuffer_data[(i * 4) + 0] = backbuffer_palette[(backbuffer_data_raw[i] * 3) + 0];
@@ -187,29 +191,24 @@ void Device_Present(void)
backbuffer_data[(i * 4) + 2] = backbuffer_palette[(backbuffer_data_raw[i] * 3) + 2];
backbuffer_data[(i * 4) + 3] = 255;
}
glBindTexture(GL_TEXTURE_2D, backbuffer_texture);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, ScreenWidth, ScreenHeight, GL_RGBA, GL_UNSIGNED_BYTE, backbuffer_data);
bool ScreenActive;
ImGuiStyle& style = ImGui::GetStyle();
style.FramePadding = ImVec2(0, 0);
ImGui::SetNextWindowSize(ImVec2(ScreenWidth, ScreenHeight));
ImGui::SetNextWindowPos(ImVec2(0,0));
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
ImGui::SetNextWindowPos(ImVec2(0, 0));
ImGui::Begin("RenderWindow", &ScreenActive, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoMouseInputs);
ImGui::PopStyleVar();
if (show_oldframebuffer)
{
ImVec2 desktopSize(ScreenWidth, ScreenHeight);
ImGui::Image((ImTextureID)backbuffer_texture, desktopSize);
}
if (show_oldframebuffer)
{
ImVec2 desktopSize(ScreenWidth, ScreenHeight);
ImGui::Image((ImTextureID)backbuffer_texture, desktopSize);
}
ImGui::End();
if (Imgui_Dialog_Function) {
Imgui_Dialog_Function();
}
@@ -450,7 +449,7 @@ void Create_Main_Window ( HANDLE instance , int command_show , int width , int h
ImGui_ImplSDL2_InitForD3D(game_window);
ImGui_ImplOpenGL3_Init();
io.Fonts->AddFontFromFileTTF("fonts/Roboto-Medium.ttf", 16.0f);
io.Fonts->AddFontFromFileTTF("fonts/Arial.ttf", 16.0f);
ImGui_NewFrame();
}
@@ -665,7 +664,7 @@ void __cdecl SetPalette(unsigned char *palette, long, unsigned long)
}
void WWSDL_ProcessEvents(KeyNumType& key, int& flags) {
void WWSDL_ProcessEvents(KeyNumType& key, int& flags, bool presentBuffer) {
static int numFramesLMouse = 0;
extern int mousex, mousey;
bool leftMouseProcessed = false;
@@ -714,6 +713,7 @@ void WWSDL_ProcessEvents(KeyNumType& key, int& flags) {
flags = GadgetClass::LEFTUP;
break;
case SDL_MOUSEBUTTONDOWN:
if (event.button.button == SDL_BUTTON_LEFT) {
flags = GadgetClass::LEFTPRESS;
@@ -780,7 +780,9 @@ void WWSDL_ProcessEvents(KeyNumType& key, int& flags) {
flags = GadgetClass::LEFTHELD;
}
Device_Present();
if (presentBuffer) {
Device_Present();
}
}
@@ -889,17 +891,23 @@ void Memory_Error_Handler(void)
GraphicBufferClass* Read_PCX_File(char* name, char* Palette, void *Buff, long Size);
void Load_Title_Screen(char *name, GraphicViewPortClass *video_page, unsigned char *palette)
{
void Load_Title_Screen(char *name, GraphicViewPortClass *video_page, unsigned char *palette) {
char filename[512];
sprintf(filename, "ui/%s", name);
COM_SetExtension(filename, sizeof(filename), ".png");
Image_t* image = Image_LoadImage(filename);
GraphicBufferClass *load_buffer;
GL_RenderImage(image, 0, 0, ScreenWidth, ScreenHeight);
load_buffer = Read_PCX_File(name, (char*)palette, NULL, 0);
if (load_buffer) {
load_buffer->Scale(*video_page, 0, 0, 0, 0, load_buffer->Get_Width(), load_buffer->Get_Height(), ScreenWidth, ScreenHeight, NULL);
// We still have to do this for palette reasons.
{
GraphicBufferClass* load_buffer;
load_buffer = Read_PCX_File(name, (char*)palette, NULL, 0);
delete load_buffer;
//if (load_buffer) {
// load_buffer->Scale(*video_page, 0, 0, 0, 0, load_buffer->Get_Width(), load_buffer->Get_Height(), ScreenWidth, ScreenHeight, NULL);
// delete load_buffer;
//}
}
}
+13 -8
View File
@@ -3734,7 +3734,7 @@ ImGuiKeyModFlags ImGui::GetMergedKeyModFlags()
return key_mod_flags;
}
void ImGui::NewFrame()
void ImGui::NewFrame(bool clearCmdList)
{
IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?");
ImGuiContext& g = *GImGui;
@@ -3777,16 +3777,21 @@ void ImGui::NewFrame()
if (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset)
g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AllowVtxOffset;
g.BackgroundDrawList.ResetForNewFrame();
g.BackgroundDrawList.PushTextureID(g.IO.Fonts->TexID);
g.BackgroundDrawList.PushClipRectFullScreen();
g.ForegroundDrawList.ResetForNewFrame();
g.ForegroundDrawList.PushTextureID(g.IO.Fonts->TexID);
g.ForegroundDrawList.PushClipRectFullScreen();
// Mark rendering data as invalid to prevent user who may have a handle on it to use it.
g.DrawData.Clear();
if (clearCmdList) {
g.BackgroundDrawList.ResetForNewFrame();
g.BackgroundDrawList.PushClipRectFullScreen();
g.ForegroundDrawList.ResetForNewFrame();
g.ForegroundDrawList.PushClipRectFullScreen();
g.DrawData.Clear();
}
g.BackgroundDrawList.PushTextureID(g.IO.Fonts->TexID);
g.ForegroundDrawList.PushTextureID(g.IO.Fonts->TexID);
// Drag and drop keep the source ID alive so even if the source disappear our state is consistent
if (g.DragDropActive && g.DragDropPayload.SourceId == g.ActiveId)
+3 -1
View File
@@ -246,7 +246,9 @@ namespace ImGui
// Main
IMGUI_API ImGuiIO& GetIO(); // access the IO structure (mouse/keyboard/gamepad inputs, time, various configuration options/flags)
IMGUI_API ImGuiStyle& GetStyle(); // access the Style structure (colors, sizes). Always use PushStyleCol(), PushStyleVar() to modify style mid-frame!
IMGUI_API void NewFrame(); // start a new Dear ImGui frame, you can submit any command from this point until Render()/EndFrame().
// jmarshall - added bool clearCmdList
IMGUI_API void NewFrame(bool clearCmdList = true); // start a new Dear ImGui frame, you can submit any command from this point until Render()/EndFrame().
// jmarshall end
IMGUI_API void EndFrame(); // ends the Dear ImGui frame. automatically called by Render(). If you don't need to render data (skipping rendering) you may call EndFrame() without Render()... but you'll have wasted CPU already! If you don't need to render, better to not create any windows and not call NewFrame() at all!
IMGUI_API void Render(); // ends the Dear ImGui frame, finalize the draw data. You can get call GetDrawData() to obtain it and run your rendering function (up to v1.60, this used to call io.RenderDrawListsFn(). Nowadays, we allow and prefer calling your render function yourself.)
IMGUI_API ImDrawData* GetDrawData(); // valid after Render() and until the next call to NewFrame(). this is what you have to render.