reimplemented unit listboxes in the map editor

This commit is contained in:
devZoGok
2023-07-02 08:17:19 +03:00
parent 208d2307ec
commit ca2d492efc
6 changed files with 44 additions and 26 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ set(BUILD_TESTS ON)
cmake_policy(SET CMP0015 NEW)
set(BUTTONS singlePlayerButton.cpp mapEditorButton.cpp newMapButton.cpp loadMapButton.cpp optionsButton.cpp exitButton.cpp tabButton.cpp okButton.cpp defaultsButton.cpp backButton.cpp consoleCommand.cpp exportButton.cpp)
set(LISTBOXES skyboxTextureListbox.cpp landTextureListbox.cpp)
set(LISTBOXES skyboxTextureListbox.cpp landTextureListbox.cpp unitListbox.cpp)
set(GUI tooltip.cpp concreteGuiManager.cpp ${BUTTONS} ${LISTBOXES})
set(STATES activeGameState.cpp inGameAppState.cpp guiAppState.cpp mapEditorAppState.cpp)
+2 -1
View File
@@ -15,6 +15,7 @@
#include "exportButton.h"
#include "skyboxTextureListbox.h"
#include "landTextureListbox.h"
#include "unitListbox.h"
namespace battleship{
using namespace std;
@@ -196,7 +197,7 @@ namespace battleship{
closable = true;
maxDisplay = (numLines > numMaxDisplay ? numMaxDisplay : numLines);
listbox = new Listbox(pos, size, lines, maxDisplay, fontPath, closable);
listbox = new UnitListbox(pos, size, lines, maxDisplay, fontPath);
break;
}
case SKYBOX_TEXTURES:
-16
View File
@@ -37,21 +37,6 @@ namespace battleship{
using namespace std;
using namespace std::filesystem;
MapEditorAppState::MapEditor::UnitListbox::UnitListbox(int startId, Vector2 pos, Vector2 size, vector<string> lines, int maxDisplay, string fontPath) : Listbox(pos, size, lines, maxDisplay, fontPath){
this->startId = startId;
}
void MapEditorAppState::MapEditor::UnitListbox::onClose(){
UnitFrameController *ufCtr = UnitFrameController::getSingleton();
int id = startId + selectedOption;
LuaManager *lm = LuaManager::getSingleton();
string modelPath = lm->getStringFromTable("basePath", vector<Index>{Index(id + 1)}) + lm->getStringFromTable("meshPath", vector<Index>{Index(id + 1)});
ufCtr->addUnitFrame(UnitFrameController::UnitFrame(modelPath, id, (int)UnitType::LAND));
ufCtr->setPlacingFrames(true);
}
MapEditorAppState::MapEditor::MapEditor(string name, Vector2 size, bool newMap){
this->newMap = newMap;
this->mapSize = size;
@@ -111,7 +96,6 @@ namespace battleship{
}
}
void MapEditorAppState::MapEditor::createWaterbody(){
Material *mat = new Material(Root::getSingleton()->getLibPath() + "texture");
mat->addBoolUniform("lightingEnabled", false);
-8
View File
@@ -24,13 +24,6 @@ namespace battleship{
public:
class MapEditor{
public:
class UnitListbox : public vb01Gui::Listbox{
public:
UnitListbox(int, vb01::Vector2, vb01::Vector2, std::vector<std::string>, int, std::string);
void onClose();
private:
int startId;
};
enum MovementAxis{
X_AXIS,
Y_AXIS,
@@ -81,7 +74,6 @@ namespace battleship{
vb01::Vector3 pushPos = vb01::Vector3::VEC_ZERO;
vb01::Vector2 mapSize;
std::vector<vb01::Texture*> skyTextures, landmassTextures, waterTextures;
UnitListbox *vehicleListbox = nullptr, *structureListbox = nullptr;
};
MapEditorAppState(std::string, vb01::Vector2, bool);
+26
View File
@@ -0,0 +1,26 @@
#include "unitListbox.h"
#include "unit.h"
#include "unitFrameController.h"
#include <luaManager.h>
namespace battleship{
using namespace std;
using namespace vb01;
using namespace vb01Gui;
using namespace gameBase;
UnitListbox::UnitListbox(Vector2 pos, Vector2 size, vector<string> lines, int maxDisplay, string fontPath) : Listbox(pos, size, lines, maxDisplay, fontPath){
}
void UnitListbox::onClose(){
UnitFrameController *ufCtr = UnitFrameController::getSingleton();
int id = selectedOption;
LuaManager *lm = LuaManager::getSingleton();
string modelPath = lm->getStringFromTable("basePath", vector<Index>{Index(id + 1)}) + lm->getStringFromTable("meshPath", vector<Index>{Index(id + 1)});
ufCtr->addUnitFrame(UnitFrameController::UnitFrame(modelPath, id, (int)UnitType::LAND));
ufCtr->setPlacingFrames(true);
}
}
+15
View File
@@ -0,0 +1,15 @@
#ifndef UNIT_LISTBOX_H
#define UNIT_LISTBOX_H
#include <listbox.h>
namespace battleship{
class UnitListbox : public vb01Gui::Listbox{
public:
UnitListbox(vb01::Vector2, vb01::Vector2, std::vector<std::string>, int, std::string);
void onClose();
private:
};
}
#endif