Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; newdatainclude.ahk
- ; by PE
- class NewDataInclude {
- LB_NEWDATA() {
- return "lbNewData"
- }
- LB_INCLUDEDFILES() {
- return "lbIncludedFiles"
- }
- BTN_ADD() {
- return "btnAdd"
- }
- ARR_GUI_CTRLS() {
- retVal := [
- ["ListBox", this.LB_NEWDATA(), "r12 +Multi x16 y36 w208", this._newDataFiles],
- ["ListBox", this.LB_INCLUDEDFILES(), "r12 +Multi x288 y36 w208", this._includedFiles],
- ["Button", this.BTN_ADD(), "w32 h32 x240 y32", ">", this.add, this],
- ]
- return retVal
- }
- __New() {
- this._ready := false
- this._includedFiles := ["index.html", "main.js", "plugins.js"]
- this._newDataFiles := ["ping.ogg", "shadow.png", "Classes.json", "bling.pak", "boop.json", "window.png", "Actors.json"]
- this.__createGui()
- }
- __createGui() {
- this._gui := Gui("-Resize")
- this._gui.SetFont("s9")
- this._guiControls := Map()
- this.__addCtrls(this.ARR_GUI_CTRLS())
- this._ready := true
- }
- __addCtrls(arrSource := []) {
- controls := arrSource
- controlsLen := controls.Length
- Loop controlsLen {
- currentCtl := controls[A_Index]
- paramsLen := currentCtl.Length
- ctlType := currentCtl[1]
- ctlName := currentCtl[2]
- ctlOptions := currentCtl[3]
- this._guiControls[ctlName] := Map()
- this._guiControls[ctlName]["type"] := ctlType
- switch this._guiControls[ctlName]["type"] {
- case "ListBox":
- ctlArraySource := currentCtl[4]
- this._guiControls[ctlName]["ocx"] :=
- this._gui.AddListBox(
- ctlOptions,
- ctlArraySource
- )
- case "Button":
- ctlCaption := currentCtl[4]
- ctlFunc := currentCtl[5]
- params := (paramsLen > 5) ? currentCtl[6] : "n/a"
- fnc := (params != "n/a") ? ctlFunc.Bind(params) : ctlFunc
- this._guiControls[ctlName]["ocx"] :=
- this._gui.AddButton(
- ctlOptions,
- ctlCaption
- )
- this._guiControls[ctlName]["ocx"].OnEvent(
- "Click",
- fnc
- )
- }
- }
- }
- ctrl(ctlName) {
- return this._guiControls[ctlName]["ocx"]
- }
- __listBox2listBox(src, target) {
- selectedItems := this.ctrl(src).Value
- if (IsObject(selectedItems)) {
- selectedItemsLen := selectedItems.Length
- itemsToMove := []
- Loop selectedItemsLen {
- sourceIdx := selectedItems[A_Index]
- ControlChooseIndex(sourceIdx, this.ctrl(src))
- item := ControlGetChoice(this.ctrl(src))
- itemsToMove.Push(item)
- }
- ; should be the same as selectedItemsLen, but I don't trust these machines.
- itemsToMoveLen := itemsToMove.Length
- if (itemsToMove.Length > 0) {
- this.ctrl(target).Add(itemsToMove)
- oldDelay := A_ControlDelay
- SetControlDelay -1
- Loop itemsToMoveLen {
- item := itemsToMove[A_Index]
- sourceIdx := ControlFindItem(item, this.ctrl(src))
- ControlDeleteItem(sourceIdx, this.ctrl(src))
- }
- }
- }
- }
- add(*) {
- source := this.LB_NEWDATA()
- target := this.LB_INCLUDEDFILES()
- if (IsObject(this.ctrl(source))) {
- this.__listBox2listBox(source, target)
- }
- }
- show() {
- if (this._ready) {
- this._gui.Show()
- }
- }
- }
- TEST := NewDataInclude()
- TEST.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement