mirror of
https://github.com/ApfelTeeSaft/PlanetFleet.git
synced 2026-08-26 19:33:38 +00:00
reimplemented unit listboxes in the map editor
This commit is contained in:
+1
-1
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user