info undo

small commit but now i gotta get to school
This commit is contained in:
SrtHero278
2024-04-25 07:42:57 -07:00
parent a04d93b7c3
commit 9d5599a1a3
2 changed files with 60 additions and 21 deletions
@@ -6,13 +6,26 @@
<set name="storedProps" value="[]" />
<exec>
import haxe.ds.StringMap;
var oldInfo = {
name: stage.stageName,
folder: stage.spritesParentFolder,
startCamX: stage.startCam.x,
startCamY: stage.startCam.y,
zoom: stage.defaultZoom,
attrib: new StringMap()
};
function col(c:Int) {
return MARGIN + (170 + XOFFSET) * c;
}
for(prop =&gt; val in stage.extra)
if(!StringTools.startsWith(prop, "stageEditor."))
for(prop =&gt; val in stage.extra) {
if(!StringTools.startsWith(prop, "stageEditor.")) {
storedProps.push(prop);
oldInfo.attrib.set(prop, val);
}
}
</exec>
<title name="title" x="MARGIN" y="30 + 16" text="Stage Info" />
@@ -78,8 +91,20 @@
for(prop in storedProps)
stage.extra.remove(prop);
for(prop in attributesList.buttons.members)
var newInfo = {
name: stage.stageName,
folder: stage.spritesParentFolder,
startCamX: stage.startCam.x,
startCamY: stage.startCam.y,
zoom: stage.defaultZoom,
attrib: new StringMap()
};
for(prop in attributesList.buttons.members) {
stage.extra.set(prop.propertyText.label.text, prop.valueText.label.text);
newInfo.attrib.set(prop.propertyText.label.text, prop.valueText.label.text);
}
FlxG.state.undos.addToUndo(CEditInfo(oldInfo, newInfo));
}
</exec>
</window>
+32 -18
View File
@@ -123,7 +123,8 @@ class StageEditor extends UIState {
"hasCloseButton" => true,
"stage" => stage,
"Stage" => Stage,
"exID" => exID
"exID" => exID,
"CEditInfo" => StageChange.CEditInfo
]
));
},
@@ -729,7 +730,16 @@ class StageEditor extends UIState {
case null:
// do nothing
case CEditInfo(oldInfo, newInfo):
//editInfo(oldInfo, false);
stage.startCam.x = oldInfo.startCamX;
stage.startCam.y = oldInfo.startCamY;
stage.defaultZoom = oldInfo.zoom;
stage.stageName = oldInfo.name;
stage.spritesParentFolder = oldInfo.folder;
for (attrib in newInfo.attrib.keys())
stage.extra.remove(attrib);
for (attrib => val in oldInfo.attrib)
stage.extra.set(attrib, val);
case CTransform(sprite, oldInfo, newInfo):
sprite.setPosition(oldInfo.x, oldInfo.y);
sprite.scale.set(oldInfo.scaleX, oldInfo.scaleY);
@@ -745,7 +755,16 @@ class StageEditor extends UIState {
case null:
// do nothing
case CEditInfo(oldInfo, newInfo):
editInfo(newInfo, false);
stage.startCam.x = newInfo.startCamX;
stage.startCam.y = newInfo.startCamY;
stage.defaultZoom = newInfo.zoom;
stage.stageName = newInfo.name;
stage.spritesParentFolder = newInfo.folder;
for (attrib in oldInfo.attrib.keys())
stage.extra.remove(attrib);
for (attrib => val in newInfo.attrib)
stage.extra.set(attrib, val);
case CTransform(sprite, oldInfo, newInfo):
sprite.setPosition(newInfo.x, newInfo.y);
sprite.scale.set(newInfo.scaleX, newInfo.scaleY);
@@ -755,20 +774,6 @@ class StageEditor extends UIState {
}
}
/*public function editInfoWithUI() {
FlxG.state.openSubState(new StageInfoScreen(stage, (_) -> {
if (_ != null) editInfo(_);
}));
}*/
public function editInfo(newInfo:Xml, addtoUndo:Bool = true) {
/*var oldInfo = stage.buildXML();
stage.applyXML(new Access(newInfo));
if (addtoUndo)
undos.addToUndo(CEditInfo(oldInfo, newInfo));*/
}
public function selectSprite(_sprite:FunkinSprite) {
if(!UIUtil.getKeyState(CONTROL, PRESSED))
_select_deselect(null, false);
@@ -1237,6 +1242,15 @@ class StageEditor extends UIState {
var line:FlxSprite = null;
}
typedef StageInfo = {
name:String,
folder:String,
startCamX:Float,
startCamY:Float,
zoom:Float,
attrib:Map<String, String>
};
typedef StageSprInfo = {
x:Float,
y:Float,
@@ -1248,7 +1262,7 @@ typedef StageSprInfo = {
}
enum StageChange {
CEditInfo(oldInfo:Xml, newInfo:Xml);
CEditInfo(oldInfo:StageInfo, newInfo:StageInfo);
CTransform(sprite:FunkinSprite, oldInfo:StageSprInfo, newInfo:StageSprInfo);
}