|
|
|
@ -23,6 +23,9 @@ class TiledCollisionEditor : public olc::PixelGameEngine |
|
|
|
|
bool dragTranslate=false; |
|
|
|
|
vf2d upperLeftDragOffset{}; |
|
|
|
|
|
|
|
|
|
bool dragNewObj=false; |
|
|
|
|
vi2d upperLeftObjTile{}; |
|
|
|
|
|
|
|
|
|
Renderable circle; |
|
|
|
|
Renderable createNewButtonImg; |
|
|
|
|
Renderable editButtonImg; |
|
|
|
@ -35,8 +38,6 @@ public: |
|
|
|
|
sAppName = "TiledCollisionEditor"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Renderable rollingCounter; |
|
|
|
|
|
|
|
|
|
Manager gui; |
|
|
|
|
|
|
|
|
|
ImageCheckBox*createNewButton; |
|
|
|
@ -60,8 +61,6 @@ public: |
|
|
|
|
std::string tilesetFilename=TILESET_DIR+"Basic Tileset.tsx"; |
|
|
|
|
Tileset&tileset=tilesets[tilesetFilename]=TSXParser{tilesetFilename}.GetData(); |
|
|
|
|
|
|
|
|
|
rollingCounter.Load("rollingcounter.png",nullptr,false,false); |
|
|
|
|
|
|
|
|
|
Renderable&tilesetImg=images[tilesetFilename]; |
|
|
|
|
tilesetImg.Load(TILESET_DIR+tileset.filename); |
|
|
|
|
|
|
|
|
@ -220,6 +219,25 @@ public: |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void NewObjectUpdate(){ |
|
|
|
|
if(GetMouse(Mouse::LEFT).bPressed){ |
|
|
|
|
const Tileset&tileset=tilesets[activeTileset]; |
|
|
|
|
|
|
|
|
|
vf2d worldCoords=view.ScreenToWorld(GetMousePos()); |
|
|
|
|
upperLeftObjTile=vf2d{round(worldCoords.x/tileset.tilewidth)*tileset.tilewidth,round(worldCoords.y/tileset.tileheight)*tileset.tileheight}; |
|
|
|
|
dragNewObj=true; |
|
|
|
|
} |
|
|
|
|
if(GetMouse(Mouse::LEFT).bReleased){ |
|
|
|
|
dragNewObj=false; |
|
|
|
|
|
|
|
|
|
const Tileset&tileset=tilesets[activeTileset]; |
|
|
|
|
//Check for intersection with other objects, if found then we deny creating this object this way.
|
|
|
|
|
for(auto&[name,obj]:tileset.objects){ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool OnUserUpdate(float fElapsedTime) override |
|
|
|
|
{ |
|
|
|
|
Clear(VERY_DARK_BLUE); |
|
|
|
@ -250,7 +268,11 @@ public: |
|
|
|
|
if(editButton->bPressed)createNewButton->bChecked=false; |
|
|
|
|
|
|
|
|
|
if(GetMouseY()<ScreenHeight()-36||GetMouseX()>72){ |
|
|
|
|
if(!dragNewObj){ |
|
|
|
|
Update(); |
|
|
|
|
}else{ |
|
|
|
|
NewObjectUpdate(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//Font test.
|
|
|
|
@ -259,7 +281,7 @@ public: |
|
|
|
|
DrawStringPropDecal({0,36},"the quick brown fox jumps over the lazy dog 1234567890 !@#$%^&*()-=_+[]{}\\;':\",./<>?~`",WHITE,{1.5f,1.5f}); |
|
|
|
|
DrawStringPropDecal({0,54},"THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG 1234567890 !@#$%^&*()-=_+[]{}\\;':\",./<>?~`",WHITE,{1.5f,1.5f}); |
|
|
|
|
*/ |
|
|
|
|
if(selectedObj.length()>0){ |
|
|
|
|
if(selectedObj.length()>0&&!dragNewObj){ |
|
|
|
|
const TilesetObject&obj=tileset.objects.at(selectedObj); |
|
|
|
|
|
|
|
|
|
Quadrilateral*highlightedQuad=nullptr; |
|
|
|
@ -294,6 +316,9 @@ public: |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}else |
|
|
|
|
if(dragNewObj){ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for(auto&[objName,obj]:tileset.objects){ |
|
|
|
|