1 /* 2 * Copyright (C) 2016-2017, by Laszlo Szeremi under the Boost license. 3 * 4 * Pixel Perfect Editor, graphics.outputScreen module 5 */ 6 7 module editor; 8 9 import std.conv; 10 11 import PixelPerfectEngine.graphics.outputScreen; 12 import PixelPerfectEngine.graphics.raster; 13 import PixelPerfectEngine.graphics.layers; 14 import PixelPerfectEngine.extbmp.extbmp; 15 16 import PixelPerfectEngine.graphics.bitmap; 17 import PixelPerfectEngine.graphics.draw; 18 //import collision; 19 import PixelPerfectEngine.system.inputHandler; 20 import PixelPerfectEngine.system.file; 21 import PixelPerfectEngine.system.etc; 22 import std.stdio; 23 import std.conv; 24 import derelict.sdl2.sdl; 25 import PixelPerfectEngine.concrete.window; 26 import PixelPerfectEngine.map.mapload; 27 import converterdialog; 28 29 public interface IEditor{ 30 public void onExit(); 31 public void newDocument(); 32 public void newLayer(); 33 public void xmpToolkit(); 34 public void passActionEvent(Event e); 35 public void createNewDocument(wstring name, int rX, int rY, int pal); 36 public void createNewLayer(string name, int type, int tX, int tY, int mX, int mY); 37 } 38 39 public class NewDocumentDialog : Window, ActionListener{ 40 public IEditor ie; 41 private TextBox[] textBoxes; 42 public this(Coordinate size, wstring title){ 43 super(size, title); 44 } 45 public this(InputHandler inputhandler){ 46 this(Coordinate(10,10,220,150),"New Document"); 47 48 Button[] buttons; 49 Label[] labels; 50 buttons ~= new Button("Ok", "ok", Coordinate(150,110,200,130)); 51 52 labels ~= new Label("Name:","",Coordinate(5,20,80,39)); 53 labels ~= new Label("RasterX:","",Coordinate(5,40,80,59)); 54 labels ~= new Label("RasterY:","",Coordinate(5,60,80,79)); 55 labels ~= new Label("N. of colors:","",Coordinate(5,80,120,99)); 56 textBoxes ~= new TextBox("","name",Coordinate(81,20,200,39)); 57 textBoxes ~= new TextBox("","rX",Coordinate(121,40,200,59)); 58 textBoxes ~= new TextBox("","rY",Coordinate(121,60,200,79)); 59 textBoxes ~= new TextBox("","pal",Coordinate(121,80,200,99)); 60 addElement(buttons[0], EventProperties.MOUSE); 61 foreach(WindowElement we; labels){ 62 addElement(we, EventProperties.MOUSE); 63 } 64 foreach(TextBox we; textBoxes){ 65 //we.addTextInputHandler(inputhandler); 66 addElement(we, EventProperties.MOUSE); 67 } 68 buttons[0].al ~= this; 69 } 70 71 public void actionEvent(Event event){ 72 if(event.source == "ok"){ 73 ie.createNewDocument(textBoxes[0].getText(), to!int(textBoxes[1].getText()), to!int(textBoxes[2].getText()), to!int(textBoxes[3].getText())); 74 75 parent.closeWindow(this); 76 } 77 } 78 } 79 80 public class NewLayerDialog : Window, ActionListener{ 81 public IEditor ie; 82 private TextBox[] textBoxes; 83 private RadioButtonGroup layerType; 84 public this(Coordinate size, wstring title){ 85 super(size, title); 86 } 87 public this(IEditor ie){ 88 this(Coordinate(10,10,220,290),"New Layer"); 89 this.ie = ie; 90 Label[] labels; 91 labels ~= new Label("Name:","",Coordinate(5,20,80,39)); 92 labels ~= new Label("TileX:","",Coordinate(5,40,80,59)); 93 labels ~= new Label("TileY:","",Coordinate(5,60,80,79)); 94 labels ~= new Label("MapX:","",Coordinate(5,80,80,99)); 95 labels ~= new Label("MapY:","",Coordinate(5,100,80,119)); 96 textBoxes ~= new TextBox("","name",Coordinate(81,20,200,39)); 97 textBoxes ~= new TextBox("","tX",Coordinate(81,40,200,59)); 98 textBoxes ~= new TextBox("","tY",Coordinate(81,60,200,79)); 99 textBoxes ~= new TextBox("","mX",Coordinate(81,80,200,99)); 100 textBoxes ~= new TextBox("","mY",Coordinate(81,100,200,119)); 101 layerType = new RadioButtonGroup("Layertype:","layertype",Coordinate(5,120,200,240),["Dummy","Tile","Tile(32Bit)","Sprite","Sprite(32Bit)"],16,1); 102 Button b = new Button("Ok","ok",Coordinate(150,245,200,265)); 103 b.al ~= this; 104 addElement(b, EventProperties.MOUSE); 105 foreach(WindowElement we; labels){ 106 addElement(we, EventProperties.MOUSE); 107 } 108 foreach(TextBox we; textBoxes){ 109 //we.addTextInputHandler(this); 110 addElement(we, EventProperties.MOUSE); 111 } 112 addElement(layerType, EventProperties.MOUSE); 113 } 114 public void actionEvent(string source, string subSource, int type, int value, wstring message){} 115 public void actionEvent(string source, int type, int value, wstring message){} 116 public void actionEvent(Event event){ 117 if(event.source == "ok"){ 118 119 switch(layerType.getValue){ 120 case 1, 2: 121 ie.createNewLayer(to!string(textBoxes[0].getText), layerType.getValue, to!int(textBoxes[1].getText), to!int(textBoxes[2].getText), to!int(textBoxes[3].getText), to!int(textBoxes[4].getText)); 122 break; 123 case 3, 4: 124 ie.createNewLayer(to!string(textBoxes[0].getText), layerType.getValue, 0, 0, 0, 0); 125 break; 126 default: break; 127 } 128 parent.closeWindow(this); 129 } 130 } 131 } 132 133 public class EditorWindowHandler : WindowHandler, ElementContainer, ActionListener{ 134 private WindowElement[] elements, mouseC, keyboardC, scrollC; 135 private ListBox layerList, prop; 136 private ListBoxColumn[] propTL, propSL, propSLE; 137 private ListBoxColumn[] layerListE; 138 public Label[] labels; 139 private int[] propTLW, propSLW, propSLEW; 140 public IEditor ie; 141 142 //public InputHandler ih; 143 144 private BitmapDrawer output; 145 public this(int sx, int sy, int rx, int ry,ISpriteLayer16Bit sl){ 146 super(sx,sy,rx,ry,sl); 147 output = new BitmapDrawer(rx, ry); 148 addBackground(output.output); 149 propTLW = [40, 320]; 150 propSLW = [160, 320, 48, 64]; 151 propSLEW = [160, 320, 40, 56]; 152 } 153 154 public void initGUI(){ 155 output.drawFilledRectangle(0, rasterX, 0, rasterY, 154); 156 layerListE ~= ListBoxColumn("Num", [""]); 157 layerListE ~= ListBoxColumn("Name", [""]); 158 layerListE ~= ListBoxColumn("Type", [""]); 159 layerList = new ListBox("layerList", Coordinate(5,7,205,98), layerListE, [30,160,64],15); 160 propTL ~= ListBoxColumn("ID", [""]); 161 propTL ~= ListBoxColumn("Name", [""]); 162 propSL ~= ListBoxColumn("Type", [""]); 163 propSL ~= ListBoxColumn("Name", [""]); 164 propSL ~= ListBoxColumn("SizeX", [""]); 165 propSL ~= ListBoxColumn("SizeY", [""]); 166 propSLE ~= ListBoxColumn("Type", [""]); 167 propSLE ~= ListBoxColumn("Name", [""]); 168 propSLE ~= ListBoxColumn("PosX", [""]); 169 propSLE ~= ListBoxColumn("PosY", [""]); 170 prop = new ListBox("prop", Coordinate(5,105,460,391), propSL, propSLW,15); 171 addElement(layerList, EventProperties.MOUSE | EventProperties.SCROLL); 172 addElement(prop, EventProperties.MOUSE | EventProperties.SCROLL); 173 addElement(new Button("New","new",Coordinate(210,5,290,25)), EventProperties.MOUSE); 174 addElement(new Button("Load","load",Coordinate(295,5,375,25)), EventProperties.MOUSE); 175 addElement(new Button("Save","save",Coordinate(380,5,460,25)), EventProperties.MOUSE); 176 addElement(new Button("Save As","saveas",Coordinate(465,5,545,25)), EventProperties.MOUSE); 177 addElement(new Button("Help","help",Coordinate(550,5,630,25)), EventProperties.MOUSE); 178 addElement(new Button("New Layer","newL",Coordinate(210,30,290,50)), EventProperties.MOUSE); 179 addElement(new Button("Del Layer","delL",Coordinate(295,30,375,50)), EventProperties.MOUSE); 180 addElement(new Button("Imp Layer","impL",Coordinate(380,30,460,50)), EventProperties.MOUSE); 181 addElement(new Button("Imp TileD","impTD",Coordinate(465,30,545,50)), EventProperties.MOUSE); 182 addElement(new Button("Imp ObjD","impOD",Coordinate(550,30,630,50)), EventProperties.MOUSE); 183 addElement(new Button("Imp Map","impM",Coordinate(210,55,290,75)), EventProperties.MOUSE); 184 addElement(new Button("Imp Img","impI",Coordinate(295,55,375,75)), EventProperties.MOUSE); 185 addElement(new Button("XMP Edit","xmp",Coordinate(380,55,460,75)), EventProperties.MOUSE); 186 addElement(new Button("Palette","pal",Coordinate(465,55,545,75)), EventProperties.MOUSE); 187 addElement(new Button("Settings","setup",Coordinate(550,55,630,75)), EventProperties.MOUSE); 188 addElement(new Button("Doc Prop","docP",Coordinate(210,80,290,100)), EventProperties.MOUSE); 189 addElement(new Button("Export","exp",Coordinate(295,80,375,100)), EventProperties.MOUSE); 190 //addElement(new Button("Save","save",Coordinate(380,80,460,100)), EventProperties.MOUSE); 191 //addElement(new Button("Save As","saveas",Coordinate(465,80,545,100)), EventProperties.MOUSE); 192 addElement(new Button("Exit","exit",Coordinate(550,80,630,100)), EventProperties.MOUSE); 193 labels ~= new Label("Layer info:","null",Coordinate(5,395,101,415)); 194 labels ~= new Label("ScrollX:","null",Coordinate(5,415,70,435)); 195 labels ~= new Label("0","sx",Coordinate(71,415,140,435)); 196 labels ~= new Label("ScrollY:","null",Coordinate(145,415,210,435)); 197 labels ~= new Label("0","sy",Coordinate(211,415,280,435)); 198 labels ~= new Label("ScrollRateX:","null",Coordinate(281,415,378,435)); 199 labels ~= new Label("0","srx",Coordinate(379,415,420,435)); 200 labels ~= new Label("ScrollRateY:","null",Coordinate(421,415,518,435)); 201 labels ~= new Label("0","sry",Coordinate(519,415,560,435)); 202 labels ~= new Label("MapX:","null",Coordinate(5,435,45,455)); 203 labels ~= new Label("0","mx",Coordinate(46,435,100,455)); 204 labels ~= new Label("MapY:","null",Coordinate(105,435,145,455)); 205 labels ~= new Label("0","my",Coordinate(146,435,200,455)); 206 labels ~= new Label("TileX:","null",Coordinate(205,435,255,455)); 207 labels ~= new Label("0","tx",Coordinate(256,435,310,455)); 208 labels ~= new Label("TileY:","null",Coordinate(315,435,365,455)); 209 labels ~= new Label("0","ty",Coordinate(366,435,420,455)); 210 foreach(WindowElement we; labels){ 211 addElement(we, 0); 212 } 213 foreach(WindowElement we; elements){ 214 we.draw(); 215 } 216 } 217 218 public StyleSheet getStyleSheet(){ 219 return defaultStyle; 220 } 221 222 public void addElement(WindowElement we, int eventProperties){ 223 elements ~= we; 224 we.elementContainer = this; 225 we.al ~= this; 226 if((eventProperties & EventProperties.KEYBOARD) == EventProperties.KEYBOARD){ 227 keyboardC ~= we; 228 } 229 if((eventProperties & EventProperties.MOUSE) == EventProperties.MOUSE){ 230 mouseC ~= we; 231 } 232 if((eventProperties & EventProperties.SCROLL) == EventProperties.SCROLL){ 233 scrollC ~= we; 234 } 235 } 236 237 public void actionEvent(string source, int type, int value, wstring message){ 238 writeln(source); 239 switch(source){ 240 case "exit": 241 ie.onExit; 242 break; 243 case "new": 244 ie.newDocument; 245 break; 246 case "newL": 247 ie.newLayer; 248 break; 249 case "xmp": 250 ie.xmpToolkit(); 251 break; 252 default: 253 254 break; 255 } 256 } 257 public void actionEvent(Event event){ 258 switch(event.source){ 259 case "exit": 260 ie.onExit; 261 break; 262 case "new": 263 ie.newDocument; 264 break; 265 case "newL": 266 ie.newLayer; 267 break; 268 case "xmp": 269 ie.xmpToolkit(); 270 break; 271 default: 272 ie.passActionEvent(event); 273 break; 274 } 275 } 276 public void actionEvent(string source, string subSource, int type, int value, wstring message){} 277 /*public Bitmap16Bit[wchar] getFontSet(int style){ 278 switch(style){ 279 case 0: return basicFont; 280 case 1: return altFont; 281 case 3: return alarmFont; 282 default: break; 283 } 284 return basicFont; 285 286 }*/ 287 /*public Bitmap16Bit getStyleBrush(int style){ 288 return styleBrush[style]; 289 }*/ 290 public void drawUpdate(WindowElement sender){ 291 output.insertBitmap(sender.getPosition().left,sender.getPosition().top,sender.output.output); 292 } 293 public void getFocus(WindowElement sender){} 294 public void dropFocus(WindowElement sender){} 295 public override void passMouseEvent(int x, int y, int state = 0){ 296 foreach(WindowElement e; mouseC){ 297 if(e.getPosition().left < x && e.getPosition().right > x && e.getPosition().top < y && e.getPosition().bottom > y){ 298 e.onClick(x - e.getPosition().left, y - e.getPosition().top, state); 299 return; 300 } 301 } 302 } 303 public override void passScrollEvent(int wX, int wY, int x, int y){ 304 foreach(WindowElement e; scrollC){ 305 if(e.getPosition().left < wX && e.getPosition().right > wX && e.getPosition().top < wX && e.getPosition().bottom > wY){ 306 307 e.onScroll(y, x, wX, wY); 308 309 return; 310 } 311 } 312 } 313 } 314 315 public class Editor : InputListener, MouseListener, ActionListener, IEditor, SystemEventListener{ 316 public OutputScreen[] ow; 317 public Raster[] rasters; 318 public InputHandler input; 319 public TileLayer[] backgroundLayers; 320 public SpriteLayer windowing; 321 public SpriteLayer32Bit bitmapPreview; 322 public bool onexit, exitDialog, newLayerDialog; 323 public WindowElement[] elements; 324 public Window test; 325 public EditorWindowHandler wh; 326 public ExtendibleMap document; 327 //public ForceFeedbackHandler ffb; 328 private uint[5] framecounter; 329 public char[40] windowTitle; 330 331 public void mouseButtonEvent(Uint32 which, Uint32 timestamp, Uint32 windowID, Uint8 button, Uint8 state, Uint8 clicks, Sint32 x, Sint32 y){ 332 //writeln(windowID); 333 } 334 public void mouseWheelEvent(uint type, uint timestamp, uint windowID, uint which, int x, int y, int wX, int wY){} 335 public void mouseMotionEvent(uint timestamp, uint windowID, uint which, uint state, int x, int y, int relX, int relY){} 336 public void keyPressed(string ID, Uint32 timestamp, Uint32 devicenumber, Uint32 devicetype){ 337 if(ID == "sysesc"){ 338 onexit = !onexit; 339 }else if(ID == "AAAAA"){ 340 //ffb.runRumbleEffect(0, 1, 100); 341 } 342 } 343 public void keyReleased(string ID, Uint32 timestamp, Uint32 devicenumber, Uint32 devicetype){} 344 public void passActionEvent(Event e){ 345 switch(e.source){ 346 case "saveas": 347 FileDialog fd = new FileDialog("Save document as","docSave",this,["*.map"],".\\",true); 348 wh.addWindow(fd); 349 break; 350 case "load": 351 FileDialog fd = new FileDialog("Load document","docLoad",this,["*.map"],".\\",false); 352 wh.addWindow(fd); 353 break; 354 default: break; 355 } 356 } 357 /*public void actionEvent(string source, int type, int value, wstring message){ 358 writeln(source); 359 360 if(source == "file"){ 361 writeln(message); 362 } 363 } 364 public void actionEvent(string source, string subSource, int type, int value, wstring message){ 365 switch(subSource){ 366 case "exitdialog": 367 if(source == "Yes"){ 368 onexit = true; 369 } 370 break; 371 default: break; 372 } 373 }*/ 374 public void actionEvent(Event event){ 375 //writeln(event.subsource); 376 switch(event.subsource){ 377 case "exitdialog": 378 if(event.source == "Yes"){ 379 onexit = true; 380 } 381 break; 382 case FileDialog.subsourceID: 383 switch(event.source){ 384 case "docSave": 385 break; 386 case "docload": 387 string path = event.path; 388 path ~= event.filename; 389 document = new ExtendibleMap(path); 390 break; 391 default: break; 392 } 393 break; 394 default: 395 break; 396 } 397 } 398 public void onQuit(){onexit = !onexit;} 399 public void controllerRemoved(uint ID){} 400 public void controllerAdded(uint ID){} 401 public void xmpToolkit(){ 402 wh.addWindow(new ConverterDialog(input,bitmapPreview)); 403 } 404 public this(string[] args){ 405 406 windowing = new SpriteLayer(); 407 bitmapPreview = new SpriteLayer32Bit(); 408 409 wh = new EditorWindowHandler(1280,960,640,480,windowing); 410 wh.ie = this; 411 412 //load the fonts 413 /*Bitmap16Bit[] fontset = loadBitmapFromFile("UIfont.vmp"); 414 for(int i; i < fontset.length; i++){ 415 wh.basicFont[to!wchar(32+i)] = fontset[i]; 416 //write(32+i, " "); 417 }*/ 418 Fontset defaultFont = loadFontsetFromXMP(new ExtendibleBitmap("sysfont.xmp"), "font"); 419 420 //load the stylesheets 421 /*Bitmap16Bit[] styleSheet = loadBitmapFromFile("UIstyle.vmp"); 422 styleSheet ~= loadBitmapFromFile("UIbuttons0.vmp"); 423 wh.styleBrush[0] = styleSheet[0]; 424 wh.styleBrush[1] = styleSheet[1]; 425 wh.styleBrush[2] = styleSheet[2]; 426 wh.styleBrush[3] = styleSheet[3]; 427 wh.styleBrush[4] = styleSheet[4]; 428 wh.styleBrush[5] = styleSheet[5]; 429 wh.styleBrush[6] = styleSheet[6]; 430 wh.styleBrush[7] = styleSheet[7]; 431 wh.styleBrush[8] = styleSheet[8]; 432 wh.styleBrush[9] = styleSheet[9]; 433 wh.styleBrush[10] = styleSheet[10]; 434 wh.styleBrush[11] = styleSheet[11]; 435 wh.styleBrush[12] = styleSheet[12]; 436 wh.styleBrush[13] = styleSheet[13]; 437 wh.styleBrush[14] = styleSheet[14]; 438 wh.styleBrush[15] = styleSheet[15]; 439 wh.styleBrush[16] = styleSheet[16]; 440 wh.styleBrush[17] = styleSheet[17];*/ 441 442 ExtendibleBitmap ssOrigin = new ExtendibleBitmap("sysdef.xmp"); 443 StyleSheet ss = new StyleSheet(); 444 ss.setImage(loadBitmapFromXMP(ssOrigin,"GUI0"),"closeButtonA"); 445 ss.setImage(loadBitmapFromXMP(ssOrigin,"GUI1"),"closeButtonB"); 446 ss.setImage(loadBitmapFromXMP(ssOrigin,"GUI0"),"checkBoxA"); 447 ss.setImage(loadBitmapFromXMP(ssOrigin,"GUI1"),"checkBoxB"); 448 ss.setImage(loadBitmapFromXMP(ssOrigin,"GUI2"),"radioButtonA"); 449 ss.setImage(loadBitmapFromXMP(ssOrigin,"GUI3"),"radioButtonB"); 450 ss.setImage(loadBitmapFromXMP(ssOrigin,"GUI4"),"upArrowA"); 451 ss.setImage(loadBitmapFromXMP(ssOrigin,"GUI5"),"upArrowB"); 452 ss.setImage(loadBitmapFromXMP(ssOrigin,"GUI6"),"downArrowA"); 453 ss.setImage(loadBitmapFromXMP(ssOrigin,"GUI7"),"downArrowB"); 454 ss.setImage(loadBitmapFromXMP(ssOrigin,"GUI8"),"plusButtonA"); 455 ss.setImage(loadBitmapFromXMP(ssOrigin,"GUI9"),"plusButtonB"); 456 ss.setImage(loadBitmapFromXMP(ssOrigin,"GUIA"),"minusButtonA"); 457 ss.setImage(loadBitmapFromXMP(ssOrigin,"GUIB"),"minusButtonB"); 458 ss.setImage(loadBitmapFromXMP(ssOrigin,"GUIC"),"leftArrowA"); 459 ss.setImage(loadBitmapFromXMP(ssOrigin,"GUID"),"leftArrowB"); 460 ss.setImage(loadBitmapFromXMP(ssOrigin,"GUIE"),"rightArrowA"); 461 ss.setImage(loadBitmapFromXMP(ssOrigin,"GUIF"),"rightArrowB"); 462 ss.addFontset(defaultFont, "default"); 463 wh.defaultStyle = ss; 464 465 wh.initGUI(); 466 467 input = new InputHandler(); 468 input.ml ~= this; 469 input.ml ~= wh; 470 input.il ~= this; 471 input.sel ~= this; 472 input.kb ~= KeyBinding(0, SDL_SCANCODE_ESCAPE, 0, "sysesc", Devicetype.KEYBOARD); 473 WindowElement.inputHandler = input; 474 //wh.ih = input; 475 //ffb = new ForceFeedbackHandler(input); 476 477 //OutputWindow.setScalingQuality("2"); 478 //OutputWindow.setDriver("software"); 479 ow ~= new OutputScreen("Pixel Perfect Editor", 1280, 960); 480 481 rasters ~= new Raster(640, 480, ow[0]); 482 ow[0].setMainRaster(rasters[0]); 483 rasters[0].addLayer(windowing); 484 rasters[0].addLayer(bitmapPreview); 485 rasters[0].setupPalette(512); 486 //loadPaletteFromFile("VDPeditUI0.pal", guiR); 487 //load24bitPaletteFromFile("VDPeditUI0.pal", rasters[0]); 488 loadPaletteFromXMP(ssOrigin, "default", rasters[0]); 489 490 //rasters[0].addRefreshListener(ow[0],0); 491 492 } 493 494 public void rudamentaryFrameCounter(){ 495 framecounter[0] = framecounter[1]; 496 framecounter[1] = SDL_GetTicks(); 497 framecounter[2]++; 498 framecounter[3] += framecounter[1] - framecounter[0]; 499 if(framecounter[3] >= 1000){ 500 //writeln(framecounter[2]); 501 framecounter[4] = framecounter[2]; 502 framecounter[2] = 0; 503 framecounter[3] = 0; 504 } 505 506 } 507 508 public void whereTheMagicHappens(){ 509 while(!onexit){ 510 input.test(); 511 512 rasters[0].refresh(); 513 if(rasters.length == 2){ 514 rasters[1].refresh(); 515 } 516 rudamentaryFrameCounter(); 517 //onexit = true; 518 } 519 } 520 public void onExit(){ 521 522 exitDialog=true; 523 DefaultDialog dd = new DefaultDialog(Coordinate(10,10,220,75), "exitdialog","U WOT M8?", "Are you fucking serious?",["Yes","No","Pls save"]); 524 dd.al ~= this; 525 wh.addWindow(dd); 526 527 } 528 public void newDocument(){ 529 NewDocumentDialog ndd = new NewDocumentDialog(input); 530 ndd.ie = this; 531 wh.addWindow(ndd); 532 } 533 public void createNewDocument(wstring name, int rX, int rY, int pal){ 534 ow ~= new OutputScreen("Edit window", to!ushort(rX*2),to!ushort(rY*2)); 535 rasters ~= new Raster(to!ushort(rX), to!ushort(rY), ow[1]); 536 rasters[1].setupPalette(pal); 537 ow[1].setMainRaster(rasters[1]); 538 //document = new MapHandler(); 539 document = new ExtendibleMap(); 540 document.metaData["name"] = to!string(name); 541 document.metaData["rX"] = to!string(rX); 542 document.metaData["rY"] = to!string(rY); 543 document.metaData["pal"] = to!string(pal); 544 } 545 public void createNewLayer(string name, int type, int tX, int tY, int mX, int mY){ 546 switch(type){ 547 case 1: 548 /*wchar[] initMap; 549 initMap.length = mX * mY;*/ 550 TileLayerData md = new TileLayerData(tX,tY,mX,mY,1,1,document.getNumOfLayers(), name); 551 /*md.name = name; 552 md.tileX = tX; 553 md.tileY = tY; 554 document.mapdataList ~= md;*/ 555 TileLayer t = new TileLayer(tX, tY); 556 t.loadMapping(mX,mY,md.mapping); 557 backgroundLayers ~= t; 558 rasters[1].addLayer(t); 559 break; 560 default: break; 561 } 562 } 563 public void newLayer(){ 564 if(document !is null){ 565 NewLayerDialog ndd = new NewLayerDialog(this); 566 wh.addWindow(ndd); 567 } 568 } 569 private void updateLayerList(){ 570 571 } 572 }