mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-26 19:43:29 +00:00
loading bar
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
initPos = {x = 850, y = 100, z = 0}
|
||||
Size = {x = 200, y = 20}
|
||||
|
||||
gui = {
|
||||
{
|
||||
guiType = GuiType.TEXT,
|
||||
text = 'Loading...',
|
||||
name = 'loading',
|
||||
pos = initPos,
|
||||
scale = {x = 0.5, y = 0.5},
|
||||
font = 'batang.ttf',
|
||||
fontFirstChar = 0,
|
||||
fontLastChar = 256,
|
||||
color = {x = 1, y = 1, z = 1, w = 1}
|
||||
},
|
||||
{
|
||||
guiType = GuiType.GUI_RECTANGLE,
|
||||
pos = {x = initPos.x, y = initPos.y + Size.y, z = initPos.z},
|
||||
size = Size,
|
||||
color = {x = 0, y = 0, z = 0, w = 1}
|
||||
},
|
||||
{
|
||||
guiType = GuiType.GUI_RECTANGLE,
|
||||
pos = {x = initPos.x + 1, y = initPos.y + Size.y + 1, z = initPos.z + .1},
|
||||
size = {x = 30, y = Size.y - 2},
|
||||
name = '_loadingBar',
|
||||
color = {x = 0, y = 0, z = 1, w = 1}
|
||||
},
|
||||
}
|
||||
+1
-1
@@ -25,7 +25,7 @@ set(BUTTONS statsButton.cpp activeStateButton.cpp minimapButton.cpp ${TRADING_BU
|
||||
set(LISTBOXES skyboxTextureListbox.cpp landTextureListbox.cpp gameObjectListbox.cpp mapListbox.cpp)
|
||||
set(GUI tooltip.cpp concreteGuiManager.cpp ${BUTTONS} ${LISTBOXES})
|
||||
|
||||
set(STATES activeGameState.cpp inGameAppState.cpp guiAppState.cpp mapEditorAppState.cpp)
|
||||
set(STATES activeGameState.cpp inGameAppState.cpp guiAppState.cpp mapEditorAppState.cpp loadingAppState.cpp)
|
||||
set(UTIL util.cpp binds.h)
|
||||
set(CONTROLLERS gameObjectFrameController.cpp cameraController.cpp)
|
||||
set(CONSOLE console.cpp abstractCommand.cpp addUnitCommand.cpp addResourceCommand.cpp addTechnologyCommand.cpp toggleDebugCommand.cpp)
|
||||
|
||||
@@ -509,6 +509,7 @@ namespace battleship{
|
||||
return guiRectangle;
|
||||
}
|
||||
|
||||
//TODO distinguish between floats and vector-like tables for scale
|
||||
Text* ConcreteGuiManager::parseText(int guiId){
|
||||
sol::state_view SOL_LUA_STATE = generateView();
|
||||
sol::table guiTable = SOL_LUA_STATE["gui"][guiId + 1];
|
||||
|
||||
+15
-7
@@ -24,9 +24,9 @@ namespace battleship{
|
||||
const int maxNumGroups = 10, NUM_MAX_ZOOMS = 75;
|
||||
const vb01::u32 IMPASS_NODE_VAL = 65535;
|
||||
|
||||
const static int numAppStates = 4;
|
||||
const static int numStaticBinds[numAppStates]{6, 0, 5, 19};
|
||||
const static int numConfBinds[numAppStates]{0, 1, 27, 0};
|
||||
const static int numAppStates = 5;
|
||||
const static int numStaticBinds[numAppStates]{6, 0, 5, 19, 0};
|
||||
const static int numConfBinds[numAppStates]{0, 1, 27, 0, 0};
|
||||
const static int maxStaticBinds = 19;
|
||||
const static int maxConfBinds = 23;
|
||||
const static int numScripts = 5;
|
||||
@@ -79,7 +79,8 @@ namespace battleship{
|
||||
Bind::LOOK_LEFT,
|
||||
Bind::LOOK_RIGHT,
|
||||
Bind::LOOK_AROUND,
|
||||
}
|
||||
},
|
||||
{}
|
||||
};
|
||||
const static Bind confBinds[numAppStates][maxConfBinds]{
|
||||
{},
|
||||
@@ -111,6 +112,7 @@ namespace battleship{
|
||||
Bind::SELECT_STRUCTURE,
|
||||
Bind::DESELECT_STRUCTURE
|
||||
},
|
||||
{},
|
||||
{}
|
||||
};
|
||||
|
||||
@@ -137,7 +139,8 @@ namespace battleship{
|
||||
Mapping::MOUSE_AXIS_LEFT,
|
||||
Mapping::MOUSE_AXIS_RIGHT,
|
||||
0
|
||||
}
|
||||
},
|
||||
{}
|
||||
};
|
||||
const static int confTriggers[numAppStates][maxConfBinds]{
|
||||
{},
|
||||
@@ -168,6 +171,7 @@ namespace battleship{
|
||||
GLFW_KEY_B,
|
||||
GLFW_KEY_ESCAPE
|
||||
},
|
||||
{},
|
||||
{}
|
||||
};
|
||||
|
||||
@@ -175,12 +179,14 @@ namespace battleship{
|
||||
{0, 1, 1, 1, 1, 1},
|
||||
{},
|
||||
{0, 0, 0, 0, 1},
|
||||
{0, 0, 0, 0, 1}
|
||||
{0, 0, 0, 0, 1},
|
||||
{}
|
||||
};
|
||||
const static bool isConfKey[numAppStates][maxConfBinds]{
|
||||
{},
|
||||
{1},
|
||||
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
|
||||
{},
|
||||
{}
|
||||
};
|
||||
|
||||
@@ -188,12 +194,14 @@ namespace battleship{
|
||||
{1, 1, 1, 1, 1, 1},
|
||||
{},
|
||||
{0, 0, 0, 0, 1},
|
||||
{0, 0, 0, 0, 1}
|
||||
{0, 0, 0, 0, 1},
|
||||
{}
|
||||
};
|
||||
const static bool isConfAction[numAppStates][maxConfBinds]{
|
||||
{},
|
||||
{1},
|
||||
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
|
||||
{},
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
@@ -59,6 +59,8 @@ namespace battleship{
|
||||
void InGameAppState::onAttached() {
|
||||
AbstractAppState::onAttached();
|
||||
|
||||
Map::getSingleton()->loadPlayerGameObjects();
|
||||
|
||||
Camera *cam = Root::getSingleton()->getCamera();
|
||||
cam->setPosition(Map::getSingleton()->getSpawnPoint(playerId) + Vector3(1, 1, 1) * configData::CAMERA_DISTANCE);
|
||||
cam->lookAt(Vector3(0, -1, -1).norm(), Vector3(0, 1, -1).norm());
|
||||
|
||||
+2
-2
@@ -2,6 +2,7 @@
|
||||
#include "concreteGuiManager.h"
|
||||
#include "gameManager.h"
|
||||
#include "mapEditorAppState.h"
|
||||
#include "loadingAppState.h"
|
||||
|
||||
#include <stateManager.h>
|
||||
|
||||
@@ -16,8 +17,7 @@ namespace battleship{
|
||||
void LoadMapButton::OkButton::onClick(){
|
||||
StateManager *sm = GameManager::getSingleton()->getStateManager();
|
||||
string name = wstringToString(listbox->getContents()[listbox->getSelectedOption()]);
|
||||
sm->attachAppState(new MapEditorAppState(name, Vector2::VEC_ZERO, false));
|
||||
ConcreteGuiManager::getSingleton()->readLuaScreenScript("mapEditor.lua");
|
||||
handleLoadingGui(new LoadingAppState(new MapEditorAppState(name, Vector2::VEC_ZERO, false), "mapEditor.lua"));
|
||||
}
|
||||
|
||||
LoadMapButton::LoadMapButton(Vector3 pos, Vector2 size) : Button(pos, size, "Load map", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf"){}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
#include "loadingAppState.h"
|
||||
#include "concreteGuiManager.h"
|
||||
#include "gameManager.h"
|
||||
#include "defConfigs.h"
|
||||
|
||||
#include <quad.h>
|
||||
#include <node.h>
|
||||
#include <vector.h>
|
||||
#include <assetManager.h>
|
||||
|
||||
#include <stateManager.h>
|
||||
|
||||
namespace battleship{
|
||||
using namespace configData;
|
||||
using namespace gameBase;
|
||||
using namespace vb01;
|
||||
using namespace std;
|
||||
|
||||
LoadingAppState::LoadingAppState(AbstractAppState *newSt, string newScr) : AbstractAppState(
|
||||
AppStateType::LOADING_STATE,
|
||||
configData::calcSumBinds(AppStateType::LOADING_STATE, true),
|
||||
configData::calcSumBinds(AppStateType::LOADING_STATE, false),
|
||||
GameManager::getSingleton()->getPath() + scripts[(int)ScriptFiles::OPTIONS]
|
||||
),
|
||||
newState(newSt),
|
||||
newScreen(newScr)
|
||||
{}
|
||||
|
||||
void LoadingAppState::onDettached(){
|
||||
GameManager::getSingleton()->getStateManager()->attachAppState(newState);
|
||||
ConcreteGuiManager::getSingleton()->readLuaScreenScript(newScreen);
|
||||
|
||||
AbstractAppState::onDettached();
|
||||
}
|
||||
|
||||
void LoadingAppState::update(){
|
||||
Node *loadingBar = ConcreteGuiManager::getSingleton()->getGuiRectangle("_loadingBar");
|
||||
Quad *quad = (Quad*)loadingBar->getMesh(0);
|
||||
quad->setSize(Vector3((1 - (float)loadableAssets.size() / initNumAssets) * 200.f, 20, 0));
|
||||
quad->updateVerts(quad->getMeshBase());
|
||||
|
||||
if(getTime() - lastUpdateTime > 5){
|
||||
AssetManager::getSingleton()->load(loadableAssets[0]);
|
||||
loadableAssets.erase(loadableAssets.begin());
|
||||
|
||||
if(loadableAssets.empty()) GameManager::getSingleton()->getStateManager()->dettachAppState(this);
|
||||
|
||||
lastUpdateTime = getTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#ifndef LOADING_APP_STATE_H
|
||||
#define LOADING_APP_STATE_H
|
||||
|
||||
#include <abstractAppState.h>
|
||||
#include <util.h>
|
||||
|
||||
namespace battleship{
|
||||
class LoadingAppState : public gameBase::AbstractAppState{
|
||||
public:
|
||||
LoadingAppState(gameBase::AbstractAppState*, std::string);
|
||||
~LoadingAppState(){}
|
||||
void onAttached(){}
|
||||
void onDettached();
|
||||
void update();
|
||||
inline void setLoadableAssets(std::vector<std::string> ls){
|
||||
this->loadableAssets = ls;
|
||||
initNumAssets = ls.size();
|
||||
}
|
||||
private:
|
||||
int initNumAssets;
|
||||
std::vector<std::string> loadableAssets;
|
||||
gameBase::AbstractAppState *newState = nullptr;
|
||||
std::string newScreen = "";
|
||||
vb01::s64 lastUpdateTime = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <stateManager.h>
|
||||
|
||||
#include "map.h"
|
||||
#include "util.h"
|
||||
#include "game.h"
|
||||
#include "player.h"
|
||||
#include "gameObject.h"
|
||||
@@ -394,16 +395,8 @@ namespace battleship{
|
||||
|
||||
//TODO move minimap loading elsewhere
|
||||
void Map::loadPlayerGameObjects(){
|
||||
AssetManager *assetManager = AssetManager::getSingleton();
|
||||
string path = GameManager::getSingleton()->getPath();
|
||||
assetManager->load(path + DEFAULT_TEXTURE);
|
||||
|
||||
sol::state_view SOL_LUA_VIEW = generateView();
|
||||
string vfxPrefix = SOL_LUA_VIEW["vfxPrefix"], gameObjPrefix = SOL_LUA_VIEW["gameObjPrefix"];
|
||||
assetManager->load(path + vfxPrefix, true);
|
||||
assetManager->load(path + gameObjPrefix, true);
|
||||
|
||||
int numPlayers = Game::getSingleton()->getNumPlayers();
|
||||
sol::state_view SOL_LUA_VIEW = generateView();
|
||||
string playerInd = "players";
|
||||
|
||||
for(int i = 0; i < numPlayers; i++){
|
||||
|
||||
+2
-4
@@ -1,6 +1,7 @@
|
||||
#include "newMapButton.h"
|
||||
#include "gameManager.h"
|
||||
#include "mapEditorAppState.h"
|
||||
#include "loadingAppState.h"
|
||||
#include "concreteGuiManager.h"
|
||||
|
||||
#include <stateManager.h>
|
||||
@@ -25,10 +26,7 @@ namespace battleship{
|
||||
atof(wstringToString(sizeX->getText()).c_str()),
|
||||
atof(wstringToString(sizeY->getText()).c_str())
|
||||
);
|
||||
StateManager *stateManager = GameManager::getSingleton()->getStateManager();
|
||||
stateManager->attachAppState(new MapEditorAppState(wstringToString(name->getText()), size, true));
|
||||
|
||||
ConcreteGuiManager::getSingleton()->readLuaScreenScript("mapEditor.lua");
|
||||
handleLoadingGui(new LoadingAppState(new MapEditorAppState(wstringToString(name->getText()), size, true), "mapEditor.lua"));
|
||||
}
|
||||
|
||||
NewMapButton::NewMapButton(Vector3 pos, Vector2 size) : Button(pos, size, "New map", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf"){}
|
||||
|
||||
+2
-6
@@ -1,6 +1,7 @@
|
||||
#include "playButton.h"
|
||||
#include "gameManager.h"
|
||||
#include "inGameAppState.h"
|
||||
#include "loadingAppState.h"
|
||||
#include "concreteGuiManager.h"
|
||||
#include "game.h"
|
||||
|
||||
@@ -70,11 +71,6 @@ namespace battleship{
|
||||
game->addPlayer(new Player(difficulty, faction, team, color, cpuPlayer, i, name));
|
||||
}
|
||||
|
||||
map->loadPlayerGameObjects();
|
||||
|
||||
guiManager->readLuaScreenScript("inGame.lua");
|
||||
|
||||
StateManager *stateManager = GameManager::getSingleton()->getStateManager();
|
||||
stateManager->attachAppState(new InGameAppState());
|
||||
handleLoadingGui(new LoadingAppState(new InGameAppState(), "inGame.lua"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
#include <cmath>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include <camera.h>
|
||||
#include <quad.h>
|
||||
#include <root.h>
|
||||
#include <vector.h>
|
||||
#include <util.h>
|
||||
#include <assetManager.h>
|
||||
|
||||
#include <stateManager.h>
|
||||
#include <solUtil.h>
|
||||
|
||||
#include <glm.hpp>
|
||||
#include <ext.hpp>
|
||||
@@ -16,11 +20,15 @@
|
||||
#include "util.h"
|
||||
#include "defConfigs.h"
|
||||
#include "gameManager.h"
|
||||
#include "concreteGuiManager.h"
|
||||
#include "guiAppState.h"
|
||||
#include "inGameAppState.h"
|
||||
#include "loadingAppState.h"
|
||||
#include "mapEditorButton.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace std::this_thread;
|
||||
using namespace std::chrono;
|
||||
using namespace glm;
|
||||
using namespace vb01;
|
||||
using namespace vb01Gui;
|
||||
@@ -28,6 +36,26 @@ using namespace vb01Gui;
|
||||
namespace battleship{
|
||||
using namespace configData;
|
||||
|
||||
void handleLoadingGui(LoadingAppState *loadState){
|
||||
ConcreteGuiManager *guiManager = ConcreteGuiManager::getSingleton();
|
||||
guiManager->readLuaScreenScript("loadingScreen.lua");
|
||||
|
||||
sol::state_view SOL_LUA_VIEW = generateView();
|
||||
string vfxPrefix = SOL_LUA_VIEW["vfxPrefix"], gameObjPrefix = SOL_LUA_VIEW["gameObjPrefix"];
|
||||
|
||||
AssetManager *assetManager = AssetManager::getSingleton();
|
||||
string path = GameManager::getSingleton()->getPath();
|
||||
vector<string> assets = vector<string>{path + DEFAULT_TEXTURE};
|
||||
|
||||
assetManager->readDir(path + vfxPrefix, assets, true);
|
||||
assetManager->readDir(path + gameObjPrefix, assets, true);
|
||||
|
||||
loadState->setLoadableAssets(assets);
|
||||
|
||||
StateManager *stateManager = GameManager::getSingleton()->getStateManager();
|
||||
stateManager->attachAppState(loadState);
|
||||
}
|
||||
|
||||
void makeTitlescreenButtons(GuiAppState *state) {
|
||||
/*
|
||||
class SpButton : public Button {
|
||||
|
||||
@@ -20,10 +20,12 @@ namespace battleship{
|
||||
typedef int s32;
|
||||
typedef long long s64;
|
||||
|
||||
enum AppStateType{GUI_STATE, IN_GAME_STATE, ACTIVE_STATE, MAP_EDITOR};
|
||||
enum AppStateType{GUI_STATE, IN_GAME_STATE, ACTIVE_STATE, MAP_EDITOR, LOADING_STATE};
|
||||
|
||||
class GuiAppState;
|
||||
class LoadingAppState;
|
||||
|
||||
void handleLoadingGui(LoadingAppState*);
|
||||
void makeTitlescreenButtons(GuiAppState*);
|
||||
std::vector<std::string> readDir(std::string, bool);
|
||||
vb01::Vector2 spaceToScreen(vb01::Vector3);
|
||||
|
||||
Reference in New Issue
Block a user