mirror of
https://github.com/jmarshall23/CnC_Remastered_Collection.git
synced 2026-08-11 23:50:51 +02:00
Internal Editor: Right click main menu moved to top down main menu.
This commit is contained in:
+1
-1
@@ -629,7 +629,7 @@ set(src_redalert
|
||||
./redalert/mapscript.cpp
|
||||
./redalert/txtprnt.cpp
|
||||
./redalert/tilesetxml.cpp
|
||||
)
|
||||
"redalert/sidebareditor.cpp")
|
||||
|
||||
set(src_external
|
||||
#glew
|
||||
|
||||
@@ -346,6 +346,8 @@ void Main_Game(int argc, char * argv[])
|
||||
if (Map_Edit_Loop()) {
|
||||
break;
|
||||
}
|
||||
|
||||
Imgui_Dialog_Function = NULL;
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
@@ -13,6 +13,10 @@ struct Image_t {
|
||||
Image_t();
|
||||
~Image_t();
|
||||
|
||||
unsigned int GetImageForHouse(int houseId, int shapeId, int frame = 0) {
|
||||
return HouseImages[houseId].image[shapeId][frame];
|
||||
}
|
||||
|
||||
char name[512];
|
||||
int64_t namehash;
|
||||
HouseImage_t HouseImages[MAX_HOUSE_COLORS];
|
||||
|
||||
@@ -3052,6 +3052,10 @@ static void Init_Bootstrap_Mixfiles(void)
|
||||
bool ok = MFCD::Cache("LOCAL.MIX");
|
||||
assert(ok);
|
||||
|
||||
new MFCD("edhi.mix", &FastKey);
|
||||
ok = MFCD::Cache("edhi.mix");
|
||||
assert(ok);
|
||||
|
||||
#if 1
|
||||
new MFCD("HIRES.MIX", &FastKey);
|
||||
ok = MFCD::Cache("HIRES.MIX");
|
||||
|
||||
+39
-96
@@ -137,6 +137,8 @@ void MapEditClass::One_Time(void)
|
||||
{
|
||||
MouseClass::One_Time();
|
||||
|
||||
editorSidebar.init();
|
||||
|
||||
/*
|
||||
** The map: a single large "button"
|
||||
*/
|
||||
@@ -560,45 +562,43 @@ void MapEditClass::AI(KeyNumType & input, int x, int y)
|
||||
}
|
||||
}
|
||||
|
||||
if (editorSidebar.mainmenu_selection != -1) {
|
||||
/*
|
||||
** Turn off placement mode
|
||||
*/
|
||||
if (PendingObject) {
|
||||
if (BaseBuilding) {
|
||||
Cancel_Base_Building();
|
||||
}
|
||||
else {
|
||||
Cancel_Placement();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Turn off trigger placement mode
|
||||
*/
|
||||
if (CurTrigger) {
|
||||
Stop_Trigger_Placement();
|
||||
}
|
||||
|
||||
/*
|
||||
** Unselect object & hide popup controls
|
||||
*/
|
||||
if (CurrentObject.Count()) {
|
||||
CurrentObject[0]->Unselect();
|
||||
Popup_Controls();
|
||||
}
|
||||
Main_Menu();
|
||||
input = KN_NONE;
|
||||
editorSidebar.mainmenu_selection = -1;
|
||||
}
|
||||
|
||||
/*
|
||||
** Trap special editing keys; if one is detected, set 'input' to 0 to
|
||||
** prevent a conflict with parent's AI().
|
||||
*/
|
||||
switch (input) {
|
||||
/*
|
||||
** F2/RMOUSE = pop up main menu
|
||||
*/
|
||||
case KN_RMOUSE:
|
||||
|
||||
/*
|
||||
** Turn off placement mode
|
||||
*/
|
||||
if (PendingObject) {
|
||||
if (BaseBuilding) {
|
||||
Cancel_Base_Building();
|
||||
} else {
|
||||
Cancel_Placement();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Turn off trigger placement mode
|
||||
*/
|
||||
if (CurTrigger) {
|
||||
Stop_Trigger_Placement();
|
||||
}
|
||||
|
||||
/*
|
||||
** Unselect object & hide popup controls
|
||||
*/
|
||||
if (CurrentObject.Count()) {
|
||||
CurrentObject[0]->Unselect();
|
||||
Popup_Controls();
|
||||
}
|
||||
Main_Menu();
|
||||
input = KN_NONE;
|
||||
break;
|
||||
|
||||
/*
|
||||
** F6 = toggle passable/impassable display
|
||||
*/
|
||||
@@ -1384,6 +1384,9 @@ void MapEditClass::Draw_It(bool forced)
|
||||
return;
|
||||
}
|
||||
|
||||
editorSidebar.draw_it();
|
||||
|
||||
|
||||
/*
|
||||
** Display the total value of all Tiberium on the map.
|
||||
*/
|
||||
@@ -1501,46 +1504,6 @@ bool MapEditClass::Mouse_Moved(void)
|
||||
return(retcode);
|
||||
}
|
||||
|
||||
int mainmenu_selection = -1;
|
||||
int mainmenu_x = -1;
|
||||
int mainmenu_y = -1;
|
||||
|
||||
void Imgui_MapEdit_MainMenu(void) {
|
||||
bool toolActive = false;
|
||||
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
style.FramePadding = ImVec2(0, 0);
|
||||
ImGui::SetNextWindowSize(ImVec2(150, 200));
|
||||
ImGui::SetNextWindowPos(ImVec2(mainmenu_x, mainmenu_y));
|
||||
ImGui::Begin("MainMenu", &toolActive, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar);
|
||||
if (ImGui::Button("New Scenario")) {
|
||||
mainmenu_selection = 0;
|
||||
}
|
||||
if(ImGui::Button("Load Scenario")) {
|
||||
mainmenu_selection = 1;
|
||||
}
|
||||
if (ImGui::Button("Save Scenario")) {
|
||||
mainmenu_selection = 2;
|
||||
}
|
||||
if (ImGui::Button("Size Map")) {
|
||||
mainmenu_selection = 3;
|
||||
}
|
||||
if (ImGui::Button("Add Game Object")) {
|
||||
mainmenu_selection = 4;
|
||||
}
|
||||
if (ImGui::Button("Scenario Options")) {
|
||||
mainmenu_selection = 5;
|
||||
}
|
||||
if (ImGui::Button("AI Options")) {
|
||||
mainmenu_selection = 6;
|
||||
}
|
||||
if (ImGui::Button("Play Scenario")) {
|
||||
mainmenu_selection = 7;
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* MapEditClass::Main_Menu -- main menu processor for map editor *
|
||||
* *
|
||||
@@ -1562,17 +1525,12 @@ void MapEditClass::Main_Menu(void)
|
||||
bool process; // menu stays up while true
|
||||
int rc;
|
||||
|
||||
Imgui_Dialog_Function = Imgui_MapEdit_MainMenu;
|
||||
mainmenu_selection = -1;
|
||||
mainmenu_x = UserInput.Mouse.X;
|
||||
mainmenu_y = UserInput.Mouse.Y;
|
||||
|
||||
/*
|
||||
** Main Menu loop
|
||||
*/
|
||||
Override_Mouse_Shape(MOUSE_NORMAL); // display default mouse cursor
|
||||
process = true;
|
||||
while (process) {
|
||||
{
|
||||
|
||||
/*
|
||||
** Invoke game callback, to update music
|
||||
@@ -1583,7 +1541,7 @@ void MapEditClass::Main_Menu(void)
|
||||
** Invoke menu
|
||||
*/
|
||||
Hide_Mouse(); // Do_Menu assumes the mouse is already hidden
|
||||
selection = mainmenu_selection;
|
||||
selection = editorSidebar.mainmenu_selection;
|
||||
|
||||
g_globalKeyNumType = KN_NONE;
|
||||
g_globalKeyFlags = 0;
|
||||
@@ -1593,16 +1551,6 @@ void MapEditClass::Main_Menu(void)
|
||||
|
||||
Show_Mouse();
|
||||
|
||||
if (UnknownKey==KN_ESC || g_globalKeyNumType == KN_RMOUSE) {
|
||||
// jmarshall - consume the RMOUSE DOWN so it doesn't bring up the context menu again.
|
||||
Buttons->Input();
|
||||
// jmarshall end
|
||||
break;
|
||||
}
|
||||
|
||||
if (selection == -1)
|
||||
continue;
|
||||
|
||||
/*
|
||||
** Process selection
|
||||
*/
|
||||
@@ -1732,13 +1680,8 @@ void MapEditClass::Main_Menu(void)
|
||||
Start_Scenario(Scen.ScenarioName);
|
||||
return;
|
||||
}
|
||||
|
||||
mainmenu_selection = selection = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
Imgui_Dialog_Function = nullptr;
|
||||
|
||||
/*
|
||||
** Restore the display:
|
||||
** - Clear HIDPAGE to erase any spurious drawing done by the menu system
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
|
||||
#include "function.h"
|
||||
#include <vector>
|
||||
#include "sidebareditor.h"
|
||||
|
||||
/*
|
||||
** This is the maximum # of ObjectTypeClasses the editor has to deal with.
|
||||
@@ -312,6 +313,8 @@ class MapEditClass : public MouseClass
|
||||
static char HealthBuf[20];
|
||||
GaugeClass *BaseGauge;
|
||||
TextLabelClass *BaseLabel;
|
||||
|
||||
SidebarEditor editorSidebar;
|
||||
public:
|
||||
static MissionType MapEditMissions[];
|
||||
};
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
// sidebareditor.cpp
|
||||
//
|
||||
#include "imgui.h"
|
||||
#include "function.h"
|
||||
#include "image.h"
|
||||
|
||||
void SidebarEditor::init() {
|
||||
metalplt = LoadEditorImage("metalplt.shp");
|
||||
|
||||
mainmenu_selection = -1;
|
||||
}
|
||||
|
||||
Image_t* SidebarEditor::LoadEditorImage(const char* name) {
|
||||
const void* shapefile = MFCD::Retrieve(name);
|
||||
if(shapefile == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int width = Get_Build_Frame_Width(shapefile);
|
||||
int height = Get_Build_Frame_Height(shapefile);
|
||||
unsigned char *shape_pointer = (unsigned char*)Build_Frame(shapefile, 0, _ShapeBuffer);
|
||||
short frameCount = Get_Build_Frame_Count(shapefile);
|
||||
|
||||
Image_t* shape_image = Image_CreateImageFrom8Bit(name, width, height, shape_pointer);
|
||||
for(int i = 1; i < frameCount; i++) {
|
||||
shape_pointer = (unsigned char*)Build_Frame(shapefile, i, _ShapeBuffer);
|
||||
Image_Add8BitImage(shape_image, 0, i, width, height, shape_pointer, NULL);
|
||||
}
|
||||
|
||||
return shape_image;
|
||||
}
|
||||
|
||||
void SidebarEditor::draw_it(void) {
|
||||
bool toolActive;
|
||||
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
style.FramePadding = ImVec2(0, 0);
|
||||
|
||||
if (ImGui::BeginMainMenuBar())
|
||||
{
|
||||
if (ImGui::BeginMenu("File"))
|
||||
{
|
||||
if (ImGui::MenuItem("New Scenario")) { mainmenu_selection = 0; }
|
||||
if (ImGui::MenuItem("Load Scenario")) { mainmenu_selection = 1; }
|
||||
if (ImGui::MenuItem("Save Scenario")) { mainmenu_selection = 2; }
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::BeginMenu("Map"))
|
||||
{
|
||||
if (ImGui::MenuItem("Size Map")) { mainmenu_selection = 3; }
|
||||
if (ImGui::MenuItem("Scenario Options")) { mainmenu_selection = 5; }
|
||||
if (ImGui::MenuItem("AI Options")) { mainmenu_selection = 6; }
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::BeginMenu("Objects"))
|
||||
{
|
||||
if (ImGui::MenuItem("Add Game Object")) { mainmenu_selection = 4; }
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenu("Run"))
|
||||
{
|
||||
if (ImGui::MenuItem("Play Scenario")) { mainmenu_selection = 7; }
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
ImGui::EndMainMenuBar();
|
||||
}
|
||||
|
||||
|
||||
//ImGui::SetNextWindowSize(ImVec2(160, ScreenHeight));
|
||||
//ImGui::SetNextWindowPos(ImVec2(ScreenWidth-160, 0));
|
||||
//ImGui::Begin("EditorSidebar", &toolActive, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar);
|
||||
// // Map Preview
|
||||
// //ImGui::Image((ImTextureID)metalplt->GetImageForHouse(0, 2), ImVec2(160, 192));
|
||||
//
|
||||
//
|
||||
//
|
||||
//ImGui::End();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// sidebareditor.h
|
||||
//
|
||||
|
||||
struct Image_t;
|
||||
|
||||
class SidebarEditor {
|
||||
public:
|
||||
void init(void);
|
||||
void draw_it(void);
|
||||
|
||||
int mainmenu_selection;
|
||||
private:
|
||||
Image_t* LoadEditorImage(const char* name);
|
||||
private:
|
||||
Image_t* metalplt;
|
||||
};
|
||||
Reference in New Issue
Block a user