Skip to content

Commit

Permalink
Unowned colors checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
SecretFox committed May 4, 2018
1 parent b1a23e0 commit dbccf9b
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 8 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DressingRoomTweaks
Lets you move dressing room left/right panels, position gets saved.
Panels must be dragged from the background(not title).
**Features**
Lets you move left/right dressing room panels, panels must be dragged from the background(not title).

**Keyboard control**
First you have to click scrollbar on the left panel, after that you can use:
Expand All @@ -9,7 +9,11 @@ First you have to click scrollbar on the left panel, after that you can use:
* Enter to equip cloth.
* Backspace to clear preview.
* Esc to close the dressing room.
* V to toggle vanity camera.
* V to toggle vanity camera.

**Unowned Colors Checkbox**
When disabled Left/Right arrow keys will skip unowned colors.
If there are no available colors then clothing won't be previewed.

[![alt text](https://i.imgur.com/812P61A.png "Download")](https://github.com/SecretFox/DressingRoomTweaks/releases)
Install: unzip to `SWL\Data\Gui\Custom\Flash`
Install: unzip to `SWL\Data\Gui\Custom\Flash`
76 changes: 72 additions & 4 deletions src/com/fox/DRTweaks/Mod.as
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
import com.GameInterface.DistributedValue;
import com.GameInterface.DistributedValueBase;
import com.GameInterface.DressingRoom;
import com.GameInterface.Game.CharacterBase;
import com.Utils.Archive;
import flash.geom.Point;
Expand All @@ -22,6 +23,8 @@ class com.fox.DRTweaks.Mod {
private var m_DressingRoom:MovieClip;
private var keyListener:Object;
private var KeyPresstimeOut;
private var m_colorCheckbox:MovieClip;
private var OwnedOnly:Boolean = false;

public function Mod(root) {
m_swfroot = root;
Expand All @@ -43,14 +46,17 @@ class com.fox.DRTweaks.Mod {
DressingRoomLeftY.SetValue(config.FindEntry("DressingRoomLeftY", undefined));
DressingRoomRightX.SetValue(config.FindEntry("DressingRoomRightX", undefined));
DressingRoomRightY.SetValue(config.FindEntry("DressingRoomRightY", undefined));
OwnedOnly = Boolean(config.FindEntry("OwnedOnly", true));

HookLayout(DressingRoomDval);
}
public function Deactivate():Archive {
var config:Archive = new Archive();
config.AddEntry("DressingRoomLeftX",DressingRoomLeftX.GetValue());
config.AddEntry("DressingRoomLeftY",DressingRoomLeftY.GetValue());
config.AddEntry("DressingRoomRightX",DressingRoomRightX.GetValue());
config.AddEntry("DressingRoomRightY",DressingRoomRightY.GetValue());
config.AddEntry("DressingRoomRightY", DressingRoomRightY.GetValue());
config.AddEntry("OwnedOnly",OwnedOnly);
return config
}
private function MoveLeft(){
Expand Down Expand Up @@ -79,6 +85,25 @@ class com.fox.DRTweaks.Mod {
clearTimeout(KeyPresstimeOut);
KeyPresstimeOut = setTimeout(Delegate.create(this, KeyPressed), 100, Key.getCode());
}
private function FindNextOwned(Entries:Array, direction, idx){
var retVal:Number = idx;
if (direction > 0){
for (var i:Number = 0; i < Entries.length; i++){
var pos = i + idx;
if (!Entries[pos]) pos -= Entries.length;
if (DressingRoom.NodeOwned(Entries[pos].m_NodeId)) return pos;
}
}else{
for (var i:Number = 0; i < Entries.length; i++){
var pos = idx-i;
if (!Entries[pos]) pos += Entries.length;
if (DressingRoom.NodeOwned(Entries[pos].m_NodeId)) return pos;
}
}
return undefined
}


private function KeyPressed(Keycode){
//private var
if (m_DressingRoom.m_RightPanel["m_CurrentMode"] == 0){
Expand All @@ -87,22 +112,35 @@ class com.fox.DRTweaks.Mod {
if (Keycode == 40 || Keycode == 38){
m_DressingRoom.m_RightPanel["ClearStickyPreview"]();
m_DressingRoom.m_RightPanel["ClearPreview"]();
var idx = 0;
if(!OwnedOnly){
if (!DressingRoom.NodeOwned(m_DressingRoom.m_RightPanel["m_ColorPicker"]["m_ColorTileList"]["dataProvider"][idx].m_NodeId)){
idx = FindNextOwned(m_DressingRoom.m_RightPanel["m_ColorPicker"]["m_ColorTileList"]["dataProvider"], 1, idx);
if (idx == undefined) return;
}
}
m_DressingRoom.m_RightPanel["m_ColorPicker"]["m_ColorTileList"].dispatchEvent({
type:"change",
item:m_DressingRoom.m_RightPanel["m_ColorPicker"]["m_ColorTileList"]["dataProvider"][0]
item:m_DressingRoom.m_RightPanel["m_ColorPicker"]["m_ColorTileList"]["dataProvider"][idx]
});
m_DressingRoom.m_RightPanel["m_ColorPicker"]["m_ColorTileList"].dispatchEvent({
type:"itemClick",
item:m_DressingRoom.m_RightPanel["m_ColorPicker"]["m_ColorTileList"]["dataProvider"][0]
item:m_DressingRoom.m_RightPanel["m_ColorPicker"]["m_ColorTileList"]["dataProvider"][idx]
});
m_DressingRoom.m_RightPanel["m_ColorPicker"]["m_ColorTileList"]["selectedIndex"] = 0;
m_DressingRoom.m_RightPanel["m_ColorPicker"]["m_ColorTileList"]["selectedIndex"] = idx;
}
//right
else if (Keycode == 39){
var idx = selected + 1;
if (!m_DressingRoom.m_RightPanel["m_ColorPicker"]["m_ColorTileList"]["dataProvider"][idx]){
idx = 0
}
if(!OwnedOnly){
if (!DressingRoom.NodeOwned(m_DressingRoom.m_RightPanel["m_ColorPicker"]["m_ColorTileList"]["dataProvider"][idx].m_NodeId)){
idx = FindNextOwned(m_DressingRoom.m_RightPanel["m_ColorPicker"]["m_ColorTileList"]["dataProvider"], 1, idx);
if (idx == undefined) return;
}
}
if(idx != selected){
m_DressingRoom.m_RightPanel["m_ColorPicker"]["m_ColorTileList"]["selectedIndex"] = idx;
m_DressingRoom.m_RightPanel["m_ColorPicker"]["m_ColorTileList"].dispatchEvent({
Expand All @@ -121,6 +159,12 @@ class com.fox.DRTweaks.Mod {
if (!m_DressingRoom.m_RightPanel["m_ColorPicker"]["m_ColorTileList"]["dataProvider"][idx]){
idx = m_DressingRoom.m_RightPanel["m_ColorPicker"]["m_ColorTileList"]["dataProvider"].length-1;
}
if(!OwnedOnly){
if (!DressingRoom.NodeOwned(m_DressingRoom.m_RightPanel["m_ColorPicker"]["m_ColorTileList"]["dataProvider"][idx].m_NodeId)){
idx = FindNextOwned(m_DressingRoom.m_RightPanel["m_ColorPicker"]["m_ColorTileList"]["dataProvider"], -1, idx);
if (idx == undefined) return;
}
}
if(idx != selected){
m_DressingRoom.m_RightPanel["m_ColorPicker"]["m_ColorTileList"]["selectedIndex"] = idx;
m_DressingRoom.m_RightPanel["m_ColorPicker"]["m_ColorTileList"].dispatchEvent({
Expand Down Expand Up @@ -175,8 +219,28 @@ class com.fox.DRTweaks.Mod {
}
}
m_DressingRoom.Layout();
var container:MovieClip = m_DressingRoom.m_LeftPanel.createEmptyMovieClip("DRTweaks", m_DressingRoom.m_LeftPanel.getNextHighestDepth());
var label:TextField = m_DressingRoom.m_LeftPanel.m_UnownedFilterText;
var format = label.getTextFormat();
// cant click what you cant see
m_DressingRoom.m_LeftPanel.m_HeaderText._visible = false;
var x = m_DressingRoom.m_LeftPanel.m_UnownedCheckBox._x-100;
var y = m_DressingRoom.m_LeftPanel.m_UnownedCheckBox._y;

m_colorCheckbox = container.attachMovie("CheckBoxNoneLabel", "m_ownedColorCheckbox",container.getNextHighestDepth(), {_x:x, _y:y});
m_colorCheckbox._width = m_DressingRoom.m_LeftPanel.m_UnownedCheckBox._width;
m_colorCheckbox._height = m_DressingRoom.m_LeftPanel.m_UnownedCheckBox._height;
m_colorCheckbox.addEventListener("click", this, "CheckboxChanged");
m_colorCheckbox.selected = OwnedOnly;

var TxtField:TextField = container.createTextField("m_ownedColor", container.getNextHighestDepth(), x, label._y, label._width, label._height);
TxtField.autoSize = "left";
TxtField.setNewTextFormat(format);
TxtField.setTextFormat(format)
TxtField.embedFonts = true;
TxtField.text = "Unowned Colours:"
TxtField._x -= TxtField._width;


m_DressingRoom.m_LeftPanel.m_Background.onPress = Delegate.create(this, MoveLeft);
m_DressingRoom.m_LeftPanel.m_Background.onRelease = Delegate.create(this, SaveLeft);
Expand All @@ -189,4 +253,8 @@ class com.fox.DRTweaks.Mod {
Key.removeListener(keyListener);
}
}

private function CheckboxChanged(event){
OwnedOnly = m_colorCheckbox.selected;
}
}

0 comments on commit dbccf9b

Please sign in to comment.