generated from sigonasr2/CPlusPlusProjectTemplate
Include text entry mode for editing the encounters
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
2141cb88db
commit
c102ef41a0
Binary file not shown.
@ -65,8 +65,23 @@ OBJECT313.000000;136.000000;11
|
||||
OBJECT313.000000;141.000000;12
|
||||
OBJECT288.000000;160.000000;9
|
||||
OBJECT224.000000;160.000000;9
|
||||
OBJECT160.000000;192.000000;8
|
||||
OBJECT256.000000;192.000000;8
|
||||
OBJECT288.000000;192.000000;8
|
||||
OBJECT224.000000;192.000000;8
|
||||
OBJECT192.000000;192.000000;7
|
||||
OBJECT192.000000;224.000000;8
|
||||
OBJECT160.000000;224.000000;8
|
||||
OBJECT288.000000;224.000000;8
|
||||
OBJECT224.000000;224.000000;8
|
||||
OBJECT256.000000;224.000000;7
|
||||
OBJECT288.000000;256.000000;8
|
||||
OBJECT256.000000;256.000000;8
|
||||
OBJECT224.000000;256.000000;8
|
||||
OBJECT192.000000;256.000000;8
|
||||
OBJECT160.000000;256.000000;8
|
||||
ENCOUNTER64.000000;512.000000;90;2
|
||||
ENCOUNTER320.000000;288.000000;25;1
|
||||
ENCOUNTER64.000000;64.000000;25;1
|
||||
ENCOUNTER64.000000;256.000000;25;1
|
||||
ENCOUNTER64.000000;64.000000;35;1
|
||||
ENCOUNTER64.000000;256.000000;100;1
|
||||
ENCOUNTER192.000000;352.000000;25;1
|
||||
ENCOUNTER320.000000;288.000000;25;2
|
44
main.cpp
44
main.cpp
@ -79,6 +79,7 @@ class Object{
|
||||
int objArrElement; //Which element in the object array this object is located in. For sorting purposes.
|
||||
bool temp=false; //If set to true, it's marked for deletion after cutscene handling.
|
||||
bool enc=false; //If set to true, it's not included in the main list of entities for map saving because it's from an encounter.
|
||||
bool dead=false; //If set to true, this object was properly part of an Entity and got declared as dead.
|
||||
//animationSpd is how long to wait before switching frames.
|
||||
bool Collision(vd2d pos) {
|
||||
GAME->SetDrawTarget(layer::COLLISION);
|
||||
@ -367,6 +368,7 @@ public:
|
||||
int ENCOUNTER_SELECTED = 0;
|
||||
int ENCOUNTER_OFFSET = 0;
|
||||
std::vector<Encounter*>ENCOUNTER_LIST;
|
||||
Encounter*EDITING_ENCOUNTER=nullptr;
|
||||
|
||||
|
||||
bool MOUSE_PRESSED_DOWN=false,MOUSE_DOWN=false,MOUSE_RELEASED=false; //TODO Implement Mouse things.
|
||||
@ -665,6 +667,9 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
}
|
||||
}break;
|
||||
case GameState::EDITOR:{
|
||||
if (IsTextEntryEnabled()) {
|
||||
return;
|
||||
}
|
||||
if (TabHeld()) {
|
||||
GAME_STATE=GameState::TILE_SELECT;
|
||||
}
|
||||
@ -815,8 +820,18 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
}
|
||||
}
|
||||
|
||||
void keyUpdates() {
|
||||
void OnTextEntryComplete(const std::string&text) override{
|
||||
if (EDITING_LAYER==layer::ENCOUNTER&&EDITING_ENCOUNTER!=nullptr) {
|
||||
int numb=0;
|
||||
for (int i=0;i<text.size();i++) {
|
||||
numb*=10;
|
||||
numb+=text[i]-'0';
|
||||
}
|
||||
EDITING_ENCOUNTER->chance=numb;
|
||||
}
|
||||
}
|
||||
|
||||
void keyUpdates() {
|
||||
if (GetKey(F1).bPressed) {
|
||||
ConsoleShow(F1,false);
|
||||
}
|
||||
@ -848,6 +863,9 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
}
|
||||
}break;
|
||||
case GameState::EDITOR:{
|
||||
if (IsTextEntryEnabled()) {
|
||||
return;
|
||||
}
|
||||
if (GetKey(F2).bPressed) {
|
||||
SaveMap(CURRENT_MAP);
|
||||
printf("Map Saved\n");
|
||||
@ -899,6 +917,15 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (EDITING_LAYER==layer::ENCOUNTER&&GetMouse(2).bPressed) {
|
||||
for (int i=0;i<CURRENT_MAP->encounters.size();i++) {
|
||||
if(CURRENT_MAP->encounters[i]->pos==HIGHLIGHTED_TILE*32) {
|
||||
EDITING_ENCOUNTER=CURRENT_MAP->encounters[i];
|
||||
TextEntryEnable(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (EDITING_LAYER==layer::OBJECT&&GetMouse(0).bPressed) {
|
||||
AddObjectToWorld(CreateObject(SELECTED_OBJ_ID,HIGHLIGHTED_TILE*32));
|
||||
} else
|
||||
@ -940,10 +967,16 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
SetDrawTarget(nullptr);
|
||||
DrawRectDecal((HIGHLIGHTED_TILE)*32-cameraPos,{32,32},YELLOW);
|
||||
if (EDITING_LAYER==layer::ENCOUNTER) {
|
||||
DrawStringPropDecal({2,2},"Editing Encounters");
|
||||
if (IsTextEntryEnabled()) {
|
||||
DrawStringPropDecal({2,2},"Input Chance: "+TextEntryGetString()+"%",YELLOW);
|
||||
} else {
|
||||
DrawStringPropDecal({2,2},"Editing Encounters");
|
||||
}
|
||||
for (auto&enc:CURRENT_MAP->encounters) {
|
||||
FillRectDecal(enc->pos-cameraPos,{WIDTH,HEIGHT},Pixel(255,0,0,64));
|
||||
DrawRectDecal(enc->pos-cameraPos,{WIDTH,HEIGHT},YELLOW);
|
||||
vi2d textOffset={2,2};
|
||||
DrawStringDecal(enc->pos-cameraPos+textOffset,std::to_string(enc->chance)+"%");
|
||||
}
|
||||
} else
|
||||
if (EDITING_LAYER==layer::OBJECT) {
|
||||
@ -976,6 +1009,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
GetMousePos().y<drawpos.y+24) {
|
||||
SELECTED_OBJ_ID=obj->id;
|
||||
EDITING_LAYER=layer::OBJECT;
|
||||
EnableLayer(layer::COLLISION,false);
|
||||
}
|
||||
FillRectDecal(drawpos,{16,24},VERY_DARK_GREY);
|
||||
DrawPartialDecal({drawpos.x,drawpos.y+8},{16,16},obj->spr->spr,{(obj->frameIndex%obj->spr->frames)*obj->spr->width,0},{obj->spr->width,obj->spr->spr->sprite->height},obj->color);
|
||||
@ -1010,6 +1044,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
GetMousePos().y<drawpos.y+24) {
|
||||
ENCOUNTER_SELECTED=enc->id;
|
||||
EDITING_LAYER=layer::ENCOUNTER;
|
||||
EnableLayer(layer::COLLISION,false);
|
||||
}
|
||||
FillRectDecal(drawpos,{16,24},VERY_DARK_GREY);
|
||||
for (int i=0;i<enc->objs.size();i+=2) {
|
||||
@ -1044,7 +1079,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
for (int y=-1;y<HEIGHT/32+2;y++) {
|
||||
int yTileOffset = cameraPos.y/32;
|
||||
for (auto&obj:OBJECTS) {
|
||||
if (!obj->drawn&&obj->GetPos().y+obj->originPoint.y>(y+yTileOffset)*32&&obj->GetPos().y+obj->originPoint.y<=(y+yTileOffset+1)*32) {
|
||||
if (!obj->drawn&&(!obj->dead||EDITING_LAYER==layer::ENCOUNTER)&&obj->GetPos().y+obj->originPoint.y>(y+yTileOffset)*32&&obj->GetPos().y+obj->originPoint.y<=(y+yTileOffset+1)*32) {
|
||||
obj->drawn=true;
|
||||
SetDrawTarget(layer::DYNAMIC);
|
||||
DrawPartialDecal(obj->GetPos()-cameraPos,obj->spr->spr,{(obj->frameIndex%obj->spr->frames)*obj->spr->width,0},{obj->spr->width,obj->spr->spr->sprite->height},obj->GetScale(),obj->color);
|
||||
@ -1681,7 +1716,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
}
|
||||
|
||||
bool PlayerCanMove(){
|
||||
return !messageBoxVisible&&PARTY_MEMBER_OBJ[0]!=nullptr;
|
||||
return !IsTextEntryEnabled()&&!messageBoxVisible&&PARTY_MEMBER_OBJ[0]!=nullptr;
|
||||
}
|
||||
|
||||
void DisplayMessageBox(std::string targetText) {
|
||||
@ -1825,6 +1860,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
data->objs[i]->obj->enc=true;
|
||||
if (!successful) {
|
||||
data->objs[i]->HP=0;
|
||||
data->objs[i]->obj->dead=true;
|
||||
}
|
||||
}
|
||||
map->encounters.push_back(data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user