//#CLIENTSIDE //Amon-Ra function onCreated(){ this.base = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; windowshow(); } //-------Gui window ---- function windowshow(){ new GuiWindowCtrl(Levelwindow) { profile = "GuiWindowProfile"; position = "10 10"; extent = "600 400"; canMove = true; canResize = true; canMaximize = true; canClose = true; text = "Level"; new GuiButtonCtrl(capture) { profile = "GuiButtonProfile"; position = "5 25"; extent = "30 25"; text = "Capture"; } new GuiTextCtrl(simpletext){ profile = "GuiTextProfile"; position = "50 25"; text = "..\scriptfiles\"; visible = true; } new GuiTextEditCtrl(levelname) { profile = "GuiTextEditProfile"; position = "120 25"; extent = "100 25"; minExtent = "100 20"; historySize = 100; password = false; canMove = false; canResize = false; text = "level.nw"; } new GuiTextEditCtrl(size) { profile = "GuiTextEditProfile"; position = "260 25"; extent = "100 25"; minExtent = "100 20"; historySize = 100; password = false; canMove = false; canResize = false; text = "16"; } new GuiButtonCtrl(save) { profile = "GuiButtonProfile"; position = "220 25"; extent = "30 25"; text = "Save"; } new GuiScrollCtrl(levelscroll) { profile = "GuiScrollProfile"; horizSizing = "width"; vertSizing = "height"; position = "5 55"; extent = "590 340"; willFirstRespond = true; hScrollBar = "dynamic"; vScrollBar = "dynamic"; constantThumbHeight = false; childMargin = "0 0"; tile = true; new GuiDrawingPanel(leveldraw) { position = "5 5"; extent = "1024 1024"; } } } } //-----Clicking buttons---------------- function capture.onAction(){ draw(); } function save.onAction(){ save(); } //----Draw Lelvel---------------------------- function draw(){ for(i=0;i<64;i++) for(j=0;j<64;j++){ this.a = int(tiles[i,j] / 512)*256 + (tiles[i,j]%16)*16; this.b = int(((tiles[i,j]%512)/16))*16; leveldraw.drawimagestretched(i*size.text,j*size.text,size.text,size.text,"pics1.png",this.a,this.b,16,16); } } //----Saving as .nw ------------ function save(){ this.t = ""; this.t.add("GLEVNW01"); for(j=0;j<64;j++){ this.a = "BOARD 0 "@j@" 64 0 "; for(i=0;i<64;i++){ this.px = int(tiles[i,j] / 512) + (tiles[i,j]%16); this.py = int(((tiles[i,j]%512)/16)); this.a = this.a @ XY_tobase64(); } this.t.add(this.a); } this.t.savelines(levelname.text,0); } //---Function to Convert Base64 to X and Y position in pics1.png------- function base64_toXY(){ this.a = "A"; //First Base 64 letter this.b = "/"; //Second Base 64 letter this.nX = int((this.base.pos(this.a)-1)/8)*16 + int((this.base.pos(this.b)-1))%16; this.nY = ((this.base.pos(this.a)-1)%8)*4 + int((this.base.pos(this.b)-1)/16); this.directReturn = this.nY*128 + this.nX; } //---Function to Convert X and Y position in pics1.png to Base64 ------- function XY_tobase64(){ //this.px is the X position in pics1.png //this.py is the Y position in pics1.png this.i := this.base.charat(int(this.px/16)*8+int(this.py/4)); this.j := this.base.charat((this.py%4)*16+(this.px%16)); return this.i @ this.j; }