123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- function AssetImageFrameEditTool::onAdd(%this)
- {
- %this.explicitModeCheckbox = new GuiCheckboxCtrl()
- {
- HorizSizing="right";
- VertSizing="bottom";
- Position="10 3";
- Extent= "285 30";
- Text = "Use Explicit Frame Mode";
- TextExtent = "280 30";
- command = %this.getID() @ ".toggleExplicitMode();";
- };
- ThemeManager.setProfile(%this.explicitModeCheckbox, "checkboxProfile");
- %this.add(%this.explicitModeCheckbox);
- %this.toolScroll = new GuiScrollCtrl()
- {
- HorizSizing="width";
- VertSizing="height";
- Position="0 40";
- Extent= getWord(%this.extent, 0) SPC (getWord(%this.extent, 1) - 40);
- hScrollBar="dynamic";
- vScrollBar="dynamic";
- constantThumbHeight="0";
- showArrowButtons="1";
- scrollBarThickness="14";
- };
- ThemeManager.setProfile(%this.toolScroll, "scrollingPanelProfile");
- ThemeManager.setProfile(%this.toolScroll, "scrollingPanelThumbProfile", "ThumbProfile");
- ThemeManager.setProfile(%this.toolScroll, "scrollingPanelTrackProfile", "TrackProfile");
- ThemeManager.setProfile(%this.toolScroll, "scrollingPanelArrowProfile", "ArrowProfile");
- %this.add(%this.toolScroll);
- %this.rowChain = new GuiChainCtrl()
- {
- HorizSizing="right";
- VertSizing="bottom";
- Position="0 0";
- Extent= "662" SPC getWord(%this.toolScroll.extent, 1);
- IsVertical="1";
- ChildSpacing="2";
- };
- ThemeManager.setProfile(%this.rowChain, "emptyProfile");
- %this.toolScroll.add(%this.rowChain);
- %this.addNewCellButton = new GuiButtonCtrl()
- {
- HorizSizing="left";
- VertSizing="bottom";
- Position="580 5";
- Extent= "110 26";
- Text = "Add Cell";
- command = %this.getID() @ ".addNewCell();";
- };
- ThemeManager.setProfile(%this.addNewCellButton, "buttonProfile");
- %this.add(%this.addNewCellButton);
- }
- function AssetImageFrameEditTool::inspect(%this, %asset)
- {
- %this.asset = %asset;
- %this.explicitModeCheckbox.setStateOn(%asset.ExplicitMode);
- %this.rowChain.deleteObjects();
- %this.addHeaderRow();
- %this.toggleExplicitMode();
- }
- function AssetImageFrameEditTool::createRows(%this)
- {
- %cellCount = %this.asset.getExplicitCellCount();
- for(%i = 0; %i < %cellCount; %i++)
- {
- %name = %this.asset.getExplicitCellName(%i);
- %width = %this.asset.getExplicitCellWidth(%i);
- %height = %this.asset.getExplicitCellHeight(%i);
- %offset = %this.asset.getExplicitCellOffset(%i);
- %this.addImageFrameRow(%name, %offset, %width, %height, %i);
- }
- }
- function AssetImageFrameEditTool::toggleExplicitMode(%this)
- {
- %explicitModeOn = %this.explicitModeCheckbox.getStateOn();
- %this.toolScroll.setVisible(%explicitModeOn);
- %this.addNewCellButton.setVisible(%explicitModeOn);
- %this.asset.setExplicitMode(%explicitModeOn);
- if(%explicitModeOn && %this.asset.getExplicitCellCount() == 0)
- {
- %this.addNewCell();
- }
- else if(%explicitModeOn)
- {
- %this.createRows();
- }
- else
- {
- %this.rowChain.deleteObjects();
- %this.addHeaderRow();
- }
- }
- function AssetImageFrameEditTool::addHeaderRow(%this)
- {
- %row = new GuiControl()
- {
- Class = "AssetImageFrameHeaderRow";
- HorizSizing="right";
- VertSizing="bottom";
- Position="0 0";
- Extent="560 22";
- };
- ThemeManager.setProfile(%row, "emptyProfile");
- %this.rowChain.add(%row);
- }
- function AssetImageFrameEditTool::addImageFrameRow(%this, %name, %offset, %width, %height, %index)
- {
- %row = new GuiControl()
- {
- Class = "AssetImageFrameEditRow";
- HorizSizing="right";
- VertSizing="bottom";
- Position="0 0";
- Extent="662 40";
- CellName = %name;
- CellOffset = %offset;
- CellWidth = %width;
- CellHeight = %height;
- CellIndex = %index;
- ImageWidth = %this.asset.getImageWidth();
- ImageHeight = %this.asset.getImageHeight();
- CellCount = %this.asset.getExplicitCellCount();
- };
- ThemeManager.setProfile(%row, "emptyProfile");
- %this.rowChain.add(%row);
- %this.startListening(%row);
- }
- function AssetImageFrameEditTool::addNewCell(%this)
- {
- %index = %this.asset.getExplicitCellCount();
- %name = "Frame" @ %index;
- %x = 0;
- %y = 0;
- %width = %this.asset.getImageWidth();
- %height = %this.asset.getImageHeight();
- %this.rowChain.callOnChildrenNoRecurse("updateCellCount", %index + 1);
- %this.asset.addExplicitCell(%x, %y, %width, %height, %name);
- %this.addImageFrameRow(%name, %x SPC %y, %width, %height, %index);
- }
- function AssetImageFrameEditTool::onCellNameChange(%this, %data)
- {
- %row = getWord(%data, 0);
- %name = getWord(%data, 1);
- if(%this.asset.getExplicitCellIndex(%name) != -1)
- {
- %row.setNameError(true);
- }
- else
- {
- %this.asset.setExplicitCell(%row.CellIndex, getWord(%row.CellOffset, 0), getWord(%row.CellOffset, 1), %row.CellWidth, %row.CellHeight, %name);
- %row.CellName = %name;
- }
- }
- function AssetImageFrameEditTool::onCellSizeChange(%this, %data)
- {
- %row = getWord(%data, 0);
- %x = getWord(%data, 1);
- %y = getWord(%data, 2);
- %width = getWord(%data, 3);
- %height = getWord(%data, 4);
- %this.asset.setExplicitCell(%row.CellIndex, %x, %y, %width, %height, %row.CellName);
- %row.CellOffset = %x SPC %y;
- %row.CellWidth = %width;
- %row.CellHeight = %height;
- }
- function AssetImageFrameEditTool::onSwapCells(%this, %data)
- {
- %index1 = getWord(%data, 0);
- %index2 = getWord(%data, 1);
- %name1 = %this.asset.getExplicitCellName(%index1);
- %width1 = %this.asset.getExplicitCellWidth(%index1);
- %height1 = %this.asset.getExplicitCellHeight(%index1);
- %offset1 = %this.asset.getExplicitCellOffset(%index1);
- %name2 = %this.asset.getExplicitCellName(%index2);
- %width2 = %this.asset.getExplicitCellWidth(%index2);
- %height2 = %this.asset.getExplicitCellHeight(%index2);
- %offset2 = %this.asset.getExplicitCellOffset(%index2);
- %this.asset.setExplicitCell(%index1, getWord(%offset2, 0), getWord(%offset2, 1), %width2, %height2, %name2);
- %this.asset.setExplicitCell(%index2, getWord(%offset1, 0), getWord(%offset1, 1), %width1, %height1, %name1);
- %row1 = %this.rowChain.getObject(%index1 + 1);
- %row2 = %this.rowChain.getObject(%index2 + 1);
- %row1.CellOffset = %offset2;
- %row1.CellWidth = %width2;
- %row1.CellHeight = %height2;
- %row1.CellName = %name2;
- %row2.CellOffset = %offset1;
- %row2.CellWidth = %width1;
- %row2.CellHeight = %height1;
- %row2.CellName = %name1;
- %row1.refresh();
- %row2.refresh();
- }
- function AssetImageFrameEditTool::onRemoveCell(%this, %index)
- {
- %this.schedule(50, "onRemoveCell2", %index);
- }
- function AssetImageFrameEditTool::onRemoveCell2(%this, %index)
- {
- %this.asset.removeExplicitCell(%index);
- %row = %this.rowChain.getObject(%index + 1);
- %row.delete();
- %count = %this.asset.getExplicitCellCount();
- for(%i = 0; %i < %this.rowChain.getCount(); %i++)
- {
- %row = %this.rowChain.getObject(%i);
- if(%row.isMethod("refresh"))
- {
- %row.CellIndex = (%i - 1);
- %row.updateCellCount(%count);
- %row.refresh();
- }
- }
- }
|