%%%%%%%%%%% % %
% %% %%
% % % % %
% % % % %
% % % % %
% % % % %
%uring % % %apper
import GUI in "%oot/lib/GUI" %well... duh
var WindowMain : int := Window.Open("graphics:max;max,nobuttonbar,noecho,nocursor,title:Turing Mapper v0.1 BETA") %Double duh
Window.SetActive(WindowMain)
%%%%%%%%%%% MAP CREATOR %%%%%%%%%%%%%%
%%% TEMP VARS %%%
var WindowNewMap : int
var TileWidthBox, TileHeightBox, MapWidthBox, MapHeightBox, SubmitButton : int %The Text Boxes
%%% Fonts %%%
var RegularFont : int := Font.New("verdana:8")% The regular print font
var LargeFont : int := Font.New("verdana:12:bold")% The Large title font
%%% Global Needed Variables %%%
var MapFrame, TileFrame : int
const MapFrameX : int := 10
const MapFrameY : int := 10
const TileFrameY : int := 10
const TileFrameX : int := maxx - 230
var MapCanvas, TileCanvas : int
var MapHorizBar, MapVertBar : int
var FileMenu,ToolsMenu,HelpMenu : int
var FileMenuItems : array 1 .. 9 of int % The file menu items.
var FileMenuNames : array 1 .. 9 of string (20) := init ("New Map","Open","Save","Save As","---","Import Tiles","Export Map","---","Quit") % Names for each file menu
var ToolsMenuItems : array 1 .. 8 of int % The file menu items.
var ToolsMenuNames : array 1 .. 8 of string (20) := init ("New Map","Open","Save","Save As","---","Import Tiles","---","Quit") % Names for each file menu
var HelpMenuItems : array 1 .. 3 of int % The file menu items.
var HelpMenuNames : array 1 .. 3 of string (20) := init ("TMap Reference","---","About TMap") % Names for each file menu
%%% Load When Open/Create Map %%%
var MapFile : string
var MapTilesAcross : int := 1
var MapTilesDown : int := 1
var MapCanvasX : int
var MapCanvasY : int
var TileWidth : int := 1
var TileHeight : int := 1
procedure blank(text:string)
end blank
procedure MenuSelected
for i : 1 .. 12
if FileMenuItems (i) = GUI.GetEventWidgetID then
Text.Locate (maxrow, 1)
end if
end for
end MenuSelected
procedure CreateMap
%%% SETS UP MAP PROPORTIONS %%%
TileWidth := strint(GUI.GetText(TileWidthBox))
TileHeight := strint(GUI.GetText(TileHeightBox))
MapTilesAcross := strint(GUI.GetText(MapWidthBox))
MapTilesDown := strint(GUI.GetText(MapHeightBox))
%%% SINCE THEY HIT CREATE, SET THE BACK WINDOW TO ACTIVE AND CLOSE THE CREATE MAP WINDOW %%%
Window.SetActive(WindowMain)
if MapTilesAcross * TileWidth >= GUI.GetWidth(MapFrame) and MapTilesDown * TileHeight >= GUI.GetHeight(MapFrame) then
MapCanvas := GUI.CreateCanvas (MapFrameX+10, MapFrameY+20,GUI.GetWidth(MapFrame)-30,GUI.GetHeight(MapFrame)-30)
else
MapCanvas := GUI.CreateCanvas (MapFrameX + 10,-(MapTilesDown * TileHeight)+GUI.GetHeight(MapFrame),MapTilesAcross * TileWidth,MapTilesDown * TileHeight)
end if
View.Update
Window.Close(WindowNewMap)
end CreateMap
procedure NewMap
WindowNewMap := Window.Open ("title:Create a New Map,position:center;center,graphics:300;130") %Open a new window, to allow them to create a new map
GUI.SetBackgroundColor(gray) %Set background color
Font.Draw("Create New Map",maxx div 2 - 75,maxy - 15,LargeFont,black)%Title
%Create the boxes, and their labels
Font.Draw("Tile Width (Width of each tile)",5,maxy - 35,RegularFont,black)
TileWidthBox := GUI.CreateTextFieldFull (maxx - 50, maxy - 35, 40,"32",blank,GUI.INDENT,RegularFont,0)
Font.Draw("Tile Height (Height of each tile)",5,maxy - 55,RegularFont,black)
TileHeightBox := GUI.CreateTextFieldFull (maxx - 50, maxy - 55, 40,"32",blank,GUI.INDENT,RegularFont,0)
Font.Draw("Map Width (Tiles Horizontally)",5,maxy - 75,RegularFont,black)
MapWidthBox := GUI.CreateTextFieldFull (maxx - 50, maxy - 75, 40,"100",blank,GUI.INDENT,RegularFont,0)
Font.Draw("Map Height (Tiles Vertically)",5,maxy - 95,RegularFont,black)
MapHeightBox := GUI.CreateTextFieldFull (maxx - 50, maxy - 95, 40,"100",blank,GUI.INDENT,RegularFont,0)
%%% THE SUBMIT BUTTON %%%
SubmitButton := GUI.CreateButton (maxx div 2 - 40, 5, 80, "Create", CreateMap)
end NewMap
procedure OpenFile
end OpenFile
procedure SaveFile
end SaveFile
procedure SaveFileAs
end SaveFileAs
procedure ImportTiles
end ImportTiles
procedure ExportMap
end ExportMap
procedure ExitProgram
GUI.Quit
end ExitProgram
procedure DisplayGUI
GUI.SetBackgroundColor(gray)
%%% FILE ITEMS %%%
FileMenu := GUI.CreateMenu ("File")
FileMenuItems (1) := GUI.CreateMenuItem (FileMenuNames (1), NewMap)
FileMenuItems (2) := GUI.CreateMenuItem (FileMenuNames (2), OpenFile)
FileMenuItems (3) := GUI.CreateMenuItem (FileMenuNames (3), SaveFile)
FileMenuItems (4) := GUI.CreateMenuItem (FileMenuNames (4), SaveFileAs)
FileMenuItems (5) := GUI.CreateMenuItem (FileMenuNames (5), MenuSelected)
FileMenuItems (6) := GUI.CreateMenuItem (FileMenuNames (6), ImportTiles)
FileMenuItems (7) := GUI.CreateMenuItem (FileMenuNames (7), ExportMap)
FileMenuItems (8) := GUI.CreateMenuItem (FileMenuNames (8), MenuSelected)
FileMenuItems (9) := GUI.CreateMenuItem (FileMenuNames (9), ExitProgram)
%%% TOOLS ITEMS %%%
ToolsMenu := GUI.CreateMenu ("Tools")
%%% HELP ITEMS %%%
HelpMenu := GUI.CreateMenu ("Help")
HelpMenuItems (1) := GUI.CreateMenuItem (HelpMenuNames (1), NewMap)
HelpMenuItems (2) := GUI.CreateMenuItem (HelpMenuNames (2), NewMap)
HelpMenuItems (3) := GUI.CreateMenuItem (HelpMenuNames (3), NewMap)
%%% MAP FRAME %%%
MapFrame := GUI.CreateFrame (MapFrameX,MapFrameY, maxx - 250, maxy - 30,GUI.INDENT) %Map Canvas Frame
%%% TILE FRAME %%%
TileFrame := GUI.CreateFrame (TileFrameX,TileFrameY, maxx - 10, maxy - 30,GUI.INDENT)
end DisplayGUI
DisplayGUI
loop
exit when GUI.ProcessEvent
end loop
|