Made a less stupid String to Class conversion function.

pull/28/head
sigonasr2 1 year ago
parent cedb465c79
commit c23c96b6b1
  1. 6
      Crawler/ClassInfo.h
  2. 8
      Crawler/ClassSelectionWindow.cpp
  3. 2
      Crawler/Version.h

@ -19,6 +19,12 @@ struct ClassInfo{
class classutils{
public:
static inline Class StringToClass(std::string className){
std::vector<std::string>classList=DATA["class_list"].GetValues();
auto it=std::find(classList.begin(),classList.end(),className);
int element=std::distance(classList.begin(),it);
return Class(1<<element);
};
static inline ClassInfo GetClassInfo(std::string className){
ClassInfo data{
DATA.GetProperty(className+".ClassName").GetString(),

@ -5,6 +5,7 @@
#include "MenuLabel.h"
#include "MenuAnimatedIconToggleButton.h"
#include "GameState.h"
#include "ClassInfo.h"
INCLUDE_game
typedef Attribute A;
@ -29,12 +30,7 @@ void Menu::InitializeClassSelectionWindow(){
classSelectionWindow->AddComponent("Back Button",backButton);
MenuComponent*confirmButton=new MenuComponent(CLASS_SELECTION,{{outlineSize.x+4-navigationButtonSize.x-2,outlineSize.y+4-navigationButtonSize.y-2},navigationButtonSize},"Confirm",[](MenuFuncData data){
std::string selectedClass=data.component->S(A::CLASS_SELECTION);
INCLUDE_DATA
std::vector<std::string>classList=DATA["class_list"].GetValues();
auto it=std::find(classList.begin(),classList.end(),selectedClass);
int element=std::distance(classList.begin(),it);
Class cl=Class(1<<element);
data.game->ChangePlayerClass(cl);
data.game->ChangePlayerClass(classutils::StringToClass(selectedClass));
GameState::ChangeState(States::GAME_RUN);
});
confirmButton->disabled=true;

@ -2,7 +2,7 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 0
#define VERSION_BUILD 2404
#define VERSION_BUILD 2405
#define stringify(a) stringify_(a)
#define stringify_(a) #a

Loading…
Cancel
Save