diff --git a/Assets/Scripts/options.lua b/Assets/Scripts/options.lua index 441a999..5868348 100644 --- a/Assets/Scripts/options.lua +++ b/Assets/Scripts/options.lua @@ -53,6 +53,7 @@ mappings = { {bind = 41, trigger = 89, action = true, bindType = 0, inOptions = false}, {bind = 42, trigger = 88, action = true, bindType = 0, inOptions = false}, {bind = 43, trigger = 87, action = true, bindType = 0, inOptions = false}, + {bind = 44, trigger = 72, action = true, bindType = 0, inOptions = false}, } graphics = { resolution = {x = 1920, y = 1080} diff --git a/binds.h b/binds.h index 8f677f9..1bf1f22 100644 --- a/binds.h +++ b/binds.h @@ -46,7 +46,8 @@ namespace battleship{ MOVE_X_AXIS, MOVE_Y_AXIS, MOVE_Z_AXIS, - CREATE_WATERBODY + CREATE_WATERBODY, + GENERATE_WEIGHTS }; } diff --git a/defConfigs.h b/defConfigs.h index 24181b9..da1c38e 100755 --- a/defConfigs.h +++ b/defConfigs.h @@ -20,7 +20,7 @@ namespace battleship{ const int maxNumGroups = 10; const static int numAppStates = 4; - const static int numStaticBinds[numAppStates]{6, 0, 5, 17}; + const static int numStaticBinds[numAppStates]{6, 0, 5, 18}; const static int numConfBinds[numAppStates]{0, 1, 22, 0}; const static int maxStaticBinds = 17; const static int maxConfBinds = 22; diff --git a/mapEditorAppState.cpp b/mapEditorAppState.cpp index 4433df9..3cda6ab 100644 --- a/mapEditorAppState.cpp +++ b/mapEditorAppState.cpp @@ -363,7 +363,15 @@ namespace battleship{ doc->SaveFile(name.c_str()); } + void MapEditorAppState::MapEditor::deleteWeights(){ + weightsGenerated = false; + } + void MapEditorAppState::MapEditor::generateWeights(){ + if(weightsGenerated) + deleteWeights(); + + weightsGenerated = true; } void MapEditorAppState::MapEditor::exportMap(){ @@ -383,6 +391,7 @@ namespace battleship{ void MapEditorAppState::update(){ radiusText->setText(L"Radius: " + to_wstring(mapEditor->getCircleRadius())); + weightsText->setText(L"Weights generated: " + to_wstring(mapEditor->isWeightsGenerated())); CameraController *camCtr = CameraController::getSingleton(); @@ -404,12 +413,19 @@ namespace battleship{ mat->addBoolUniform("texturingEnabled", false); mat->addVec4Uniform("diffuseColor", Vector4::VEC_IJKL); - radiusText = new Text(GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", L""); + string fontPath = GameManager::getSingleton()->getPath() + "Fonts/batang.ttf"; + radiusText = new Text(fontPath, L""); radiusText->setMaterial(mat); + weightsText = new Text(fontPath, L""); + weightsText->setMaterial(mat); - Node *node = new Node(Vector3(0, 100, 0)); - node->addText(radiusText); - root->getGuiNode()->attachChild(node); + Node *radiusNode = new Node(Vector3(0, 100, 0)); + radiusNode->addText(radiusText); + root->getGuiNode()->attachChild(radiusNode); + + Node *weightsNode = new Node(Vector3(0, 200, 0)); + weightsNode->addText(weightsText); + root->getGuiNode()->attachChild(weightsNode); } void MapEditorAppState::onDettached(){} @@ -483,6 +499,9 @@ namespace battleship{ mapEditor->setMovementAxis(axis); } + break; + case Bind::GENERATE_WEIGHTS: + mapEditor->generateWeights(); break; } } diff --git a/mapEditorAppState.h b/mapEditorAppState.h index 84b3cff..9efa0c0 100644 --- a/mapEditorAppState.h +++ b/mapEditorAppState.h @@ -42,6 +42,7 @@ namespace battleship{ void createWaterbody(); void moveTerrainObject(float); void exportMap(); + void generateWeights(); inline TerrainObject* getSelectedTerrainObject(){return selectedTerrainObject;} inline float getGuiThreshold(){return guiThreshold;} inline float getCircleRadius(){return circleRadius;} @@ -52,20 +53,21 @@ namespace battleship{ inline void setMovingTerrainObject(bool m){movingTerrainObject = m;} inline MovementAxis getMovementAxis(){return movementAxis;} inline void setMovementAxis(MovementAxis m){movementAxis = m;} + inline bool isWeightsGenerated(){return weightsGenerated;} private: void generatePlane(vb01::Vector2); void prepareGui(); void prepareTextures(std::string, bool, std::vector&); void toggleSelection(TerrainObject*, bool); void parseLandmass(); - void generateWeights(); + void deleteWeights(); inline vb01::Texture* getSkyTexture(int i){return skyTextures[i];} inline vb01::Texture* getLandmassTexture(int i){return landmassTextures[i];} Map *map; TerrainObject *selectedTerrainObject = nullptr; MovementAxis movementAxis = X_AXIS; - bool pushing = false, movingTerrainObject = false, newMap; + bool pushing = false, movingTerrainObject = false, weightsGenerated = false, newMap; const float MIN_RADIUS = 1, MAX_RADIUS = 100, INCREASE_RATE = 1; const int NUM_SUBDIVS = 100; float circleRadius = MIN_RADIUS, guiThreshold = 200; @@ -87,7 +89,7 @@ namespace battleship{ std::string mapName; vb01::Vector2 mapSize; bool newMap; - vb01::Text *radiusText = nullptr; + vb01::Text *radiusText = nullptr, *weightsText = nullptr; }; }