Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help With Windows
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
TheEvilOne




PostPosted: Mon Apr 18, 2005 5:38 pm   Post subject: Help With Windows

Ok. I keep getting this weird error, whenever I close a window. It only happens sometimes, and I have no idea why. Currently, it opens a new window, asks for your input, takes your input to store into variables, and makes a canvas depending on size constraints.

When it closes the window, the program errors and crashes though x_x

Anyone help me?

EDIT: Go to file -> New Map to see what im talking about -.-

code:

%%%%%%%%%%%  %           %
     %       %%         %%
     %       % %       % %
     %       %  %     %  %
     %       %   %   %   %
     %       %    % %    %
     %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
Sponsor
Sponsor
Sponsor
sponsor
Shyfire




PostPosted: Wed Apr 20, 2005 8:47 am   Post subject: (No subject)

sorry dude i'm just as lost as you are Question Question
StarGateSG-1




PostPosted: Wed Apr 20, 2005 11:12 am   Post subject: (No subject)

There is nothing wornf with thta program it runs fine, you could have an older version of turing than me, I have 4.0.5. It could also be that you don't have a close window handler, I can look it up for you but, i would prefer it you went into turing help and checked.
TheEvilOne




PostPosted: Thu Apr 21, 2005 8:56 am   Post subject: (No subject)

close window handler? Confused
StarGateSG-1




PostPosted: Thu Apr 21, 2005 1:34 pm   Post subject: (No subject)

as far as I can see when you close the new map window, then the game crashes or ends that is the only thing I can think of.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: