Jump to content

Need help with getting back to the main GUI


Recommended Posts

I need help getting back to the main Gui with this script.

#include <GUIConstants.au3>

#region - Global

Global $MainGUI; THE MAIN GUI
Global $Width = 700; THE WIDTH OF ALL GUIS
Global $Height = 500; THE HEIGHT OF ALL GUIS
Global $Filemenu; FILE MENU IN THE MAIN GUI 
Global $Newgameitem; ITEM IN THE FILE MENU OF THE MAIN GUI
Global $Exititem; ITEM IN THE FILE MENU OF THE MAIN GUI
Global $ButtonA; BUTTON NAMED 'A' IN THE MAIN GUI
Global $ButtonB; BUTTON NAMED 'B' IN THE MAIN GUI
Global $ButtonC; BUTTON NAMED 'C' IN THE MAIN GUI
Global $Questlabel; A LABEL USED TO TRANSMIT THE DATA FROM THE QUEST.INI FILE TO THE MAIN GUI 
Global $msg; IS USED TO GET THE MESSAGES FROM THE GUI
Global $Newcount = IniRead ("Character.ini", "Counter", "count", "0" ) + 1; IS USED WITH - Iniwrite ( "Character.ini", "Counter", "count", $Newcount ) - SO THAT $Count = IniRead ("Character.ini", "Counter", "count", "0" ) - WILL EQUAL A NEW VALUE
Global $Count = IniRead ("Character.ini", "Counter", "count", "0" ); IS USED WITH $QuestA, $QuestB AND $QuestC SO THAT THEY WILL READ DIFFERENT LINES AS THE BUTTONS A, B AND C ARE PUSH AND THEN SEND THE DATA TO THE LABEL NAMED $Questlabel
Global $QuestA = IniRead ("Quest.ini", "QuestA",$Count,"error"); DATA TO BE SENT TO THE LABEL
Global $QuestB = IniRead ("Quest.ini", "QuestB",$Count,"error"); DATA TO BE SENT TO THE LABEL
Global $QuestC = IniRead ("Quest.ini", "QuestC",$Count,"error"); DATA TO BE SENT TO THE LABEL

Global $characterName = IniRead ( "character.ini", "character", "name", "unknown" )
Global $maxlife = IniRead ( "character.ini", "character", "maxlife", "unknown" ) 
Global $life = IniRead ( "character.ini", "character", "life", "unknown" )
Global $def = IniRead ( "character.ini", "character", "def", "unknown" )
Global $tohit = IniRead ( "character.ini", "character", "tohit", "unknown" )
Global $dam = IniRead ( "character.ini", "character", "dam", "unknown" )

#region - Character Setup GUI Globals

Global $CharactersetupGUI; THE GUI THAT IS USED TO SET UP THE CHARACTER IN THE GAME AT THE START(THIS GUI IS STILL BARE)

#endregion
#region - Combat GUI Globals
Global $CombatGUI; THE GUI USED FOR COMBAT IN THE GAME(THIS GUI IS STILL BARE)
Global $ButtonAttack; A BUTTON IN THE COMBAT GUI THAT IS TO BE USED TO ATTACK
Global $ButtonDefend
Global $ButtonRun


#endregion
#endregion


#Region - RPG GUI Create
$MainGUI = GUICreate ("RPG",$width, $Height)

$Filemenu = GuiCtrlCreateMenu ("File")
$Newgameitem = GUICtrlCreateMenuitem ("New Game", $Filemenu)
$Exititem = GuiCtrlCreateMenuitem ("Exit", $Filemenu)
$ButtonA = GUICtrlCreateButton ("A.", 100,440,70,20)
$ButtonB = GUICtrlCreateButton ("B.", 315,440,70,20)
$ButtonC = GUICtrlCreateButton ("C.", 530,440,70,20)
$Questlabel = GUICtrlCreateLabel("Welcome to my RPG. Choose a button. Either button A,B or C and see what the result is.", 10, 10, 500, 400);THE STARTING LINE OF THE LABEL
GUICtrlSetData($Questlabel,"Welcome to my RPG. Choose a button. Either button A,B or C and see what the result is.")
          ;BETWEEN COLUMES 1 AND 2 AND ON TOP OF
            GUICtrlCreateLabel ($characterName,  600, 25, 40, 15) 
        ;COLUME 1
            GUICtrlCreateLabel ("Stat",  565, 40, 40, 15) 
            GUICtrlCreateLabel ("Max Life",  565, 55, 40, 15)
            GUICtrlCreateLabel ("Life",  565, 70, 40, 15)            
            GUICtrlCreateLabel ("Def",  565, 85, 40, 15)
            GUICtrlCreateLabel ("To Hit",  565, 100, 40, 15) 
            GUICtrlCreateLabel ("Dam",  565, 115, 40, 15) 
          ;COLUME 2            
            GUICtrlCreateLabel ("Value",  635, 40, 40, 15) 
            GUICtrlCreateLabel ($MaxLife,  635, 55, 40, 15)
            GUICtrlCreateLabel ($Life,  635, 70, 40, 15)            
            GUICtrlCreateLabel ($Def,  635, 85, 40, 15)
            GUICtrlCreateLabel ($ToHit,  635, 100, 40, 15) 
            GUICtrlCreateLabel ($Dam,  635, 115, 40, 15) 

GuiSetState(@SW_SHOW)
#endregion

#region - Combat GUI Create
$CombatGUI = GUICreate ("Combat", $width, $Height)
$ButtonAttack = GUICtrlCreateButton ("Attack.", 100,440,70,20)
$ButtonDefend = GUICtrlCreateButton ("Defend", 315,440,70,20)
$ButtonRun = GUICtrlCreateButton ("Run.", 530,440,70,20)

;BETWEEN COLUMES 1 AND 2 AND ON TOP OF THEM
            GUICtrlCreateLabel ($characterName,  600, 25, 40, 15) 
        ;COLUME 1
            GUICtrlCreateLabel ("Stat",  565, 40, 40, 15) 
            GUICtrlCreateLabel ("Max Life",  565, 55, 40, 15)
            GUICtrlCreateLabel ("Life",  565, 70, 40, 15)            
            GUICtrlCreateLabel ("Def",  565, 85, 40, 15)
            GUICtrlCreateLabel ("To Hit",  565, 100, 40, 15) 
            GUICtrlCreateLabel ("Dam",  565, 115, 40, 15) 
          ;COLUME 2            
            GUICtrlCreateLabel ("Value",  635, 40, 40, 15) 
            GUICtrlCreateLabel ($MaxLife,  635, 55, 40, 15)
            GUICtrlCreateLabel ($Life,  635, 70, 40, 15)            
            GUICtrlCreateLabel ($Def,  635, 85, 40, 15)
            GUICtrlCreateLabel ($ToHit,  635, 100, 40, 15) 
            GUICtrlCreateLabel ($Dam,  635, 115, 40, 15) 
GuiSetState(@SW_HIDE)
#endregion

#region - Character Setup  GUI Create 
$CharactersetupGUI = GUICreate ("Character Setup", $width, $Height)
GuiSetState(@SW_HIDE)


#endregion

#Region - GUI SelectLoop

While 1
    $msg = GUIGetMsg()

Select

    Case $msg = -3;$GUI_EVENT_CLOSE
        Iniwrite ( "Character.ini", "Counter", "count", "0" ); THIS IS TEMPORARY LINE SO I DON'T HAVE TO REWRITE THE VALUE OF THE COUNT IN THE CHARACTER.INI FILE. I PLAN ON REMOVING IT WHEN I AM DONE SO THAT BY NOT RESETTING THE VAULE TO ZERO IT WILL BE LIKE AN AUTOMATIC WAY OF SAVING THE GAME IN PROGRESS.
    ExitLoop

    Case $msg = $Newgameitem
        GUISetState(@SW_HIDE,$MainGUI)
        GUISetState(@SW_SHOW,$CharactersetupGUI)
        GUISetState(@SW_HIDE,$CombatGUI)
    Case $msg = $exititem
            ExitLoop
    
Case $msg = $ButtonA 
         $Newcount = IniRead ("Character.ini", "Counter", "count", "0" ) + 1
         Iniwrite ( "Character.ini", "Counter", "count", $Newcount )
         $Count = IniRead ("Character.ini", "Counter", "count", "0" )
         $QuestA = IniRead ("Quest.ini", "QuestA",$Count,"error")
         GUICtrlSetData($Questlabel,$QuestA);CHANGES THE DATA IN THE LABEL TO $QuestA
         
         
         
    Case $msg = $ButtonB 
         $Newcount = IniRead ("Character.ini", "Counter", "count", "0" ) + 1
         Iniwrite ( "Character.ini", "Counter", "count", $Newcount )
         $Count = IniRead ("Character.ini", "Counter", "count", "0" )
         $QuestB = IniRead ("Quest.ini", "QuestB",$Count,"error")
         GUICtrlSetData($Questlabel,$QuestB);CHANGES THE DATA IN THE LABEL TO $QuestB
         

    Case $msg = $ButtonC 
         $Newcount = IniRead ("Character.ini", "Counter", "count", "0" ) + 1
         Iniwrite ( "Character.ini", "Counter", "count", $Newcount )
         $Count = IniRead ("Character.ini", "Counter", "count", "0" )
         $QuestC = IniRead ("Quest.ini", "QuestC",$Count,"error")
         GUICtrlSetData($Questlabel,$QuestC);CHANGES THE DATA IN THE LABEL TO $QuestC
    
    Case $QuestA = "combat"  
        GUISetState(@SW_HIDE,$MainGUI)
        GUISetState(@SW_HIDE,$CharactersetupGUI)
        GUISetState(@SW_SHOW,$CombatGUI)
    Case $QuestB = "combat"  
        GUISetState(@SW_HIDE,$MainGUI)
        GUISetState(@SW_HIDE,$CharactersetupGUI)
        GUISetState(@SW_SHOW,$CombatGUI)
    Case $QuestC = "combat"  
        GUISetState(@SW_HIDE,$MainGUI)
        GUISetState(@SW_HIDE,$CharactersetupGUI)
        GUISetState(@SW_SHOW,$CombatGUI)
    Case $msg = $ButtonRun 
        GUISetState(@SW_SHOW,$MainGUI)
        GUISetState(@SW_HIDE,$CharactersetupGUI)
        GUISetState(@SW_HIDE,$CombatGUI)
        
        
    
EndSelect

WEnd
#EndRegion

Here is the .Ini file named Quest.ini

[QuestA]
0=Welcome to my RPG. Choose a button. Either button A,B or C and see what the result is.
1=a1
2=a2
3=a3
4=a4
5=a5
6=a6
7=a7
8=a8
9=a9
10=a10
11=a11
12=a12
13=a13
14=a14
15=a15
16=a16
[QuestB]
1=b1
2=b2
3=b3
4=b4
5=b5
6=b6
7=b7
8=b8
9=b9
10=b10
11=b11
12=b12
13=b13
14=b14
15=b15
16=b16
[QuestC]
1=c1
2=c2
3=combat
4=c4
5=c5
6=c6
7=c7
8=c8
9=c9
10=c10
11=c11
12=c12
13=c13
14=c14
15=c15
16=c16
[1]
encountertext=
name=monster1
maxlife=20
life=1
def=9
tohit=8
dam=7
itemcode=
[2]
encountertext=
name=monster2
maxlife=20
life=1
def=9
tohit=8
dam=7
itemcode=
[Itemcode];code for reading the item
1=
[Itemcodetext];this well go with the itemcode, for display purpose only.
1=

And the .Ini file named Character.ini

[character]
name=quick
maxlife=20
life=1
def=9
tohit=8
dam=7
[Counter]
count=0

I want to go back to the main gui when I push the run button in the combat gui and it is not doing it. Look at the last case statement;

Case $msg = $ButtonRun 
  GUISetState(@SW_SHOW,$MainGUI)
  GUISetState(@SW_HIDE,$CharactersetupGUI)
  GUISetState(@SW_HIDE,$CombatGUI)

I thought this would do it, but I think that these lines are stopping it from working;

Case $QuestA = "combat"  
  GUISetState(@SW_HIDE,$MainGUI)
  GUISetState(@SW_HIDE,$CharactersetupGUI)
  GUISetState(@SW_SHOW,$CombatGUI)
    Case $QuestB = "combat"  
  GUISetState(@SW_HIDE,$MainGUI)
  GUISetState(@SW_HIDE,$CharactersetupGUI)
  GUISetState(@SW_SHOW,$CombatGUI)
    Case $QuestC = "combat"  
  GUISetState(@SW_HIDE,$MainGUI)
  GUISetState(@SW_HIDE,$CharactersetupGUI)
  GUISetState(@SW_SHOW,$CombatGUI)

But with out those lines, I can not get to the combat gui. Can anyone me help with this?

Edited by quick_sliver007

.

Link to comment
Share on other sites

Hi Chris,

I didn't know this post was here when I posted the fix to this same post at Yahoo Groups.

<{POST_SNAPBACK}>

I been using more then one furum and I just figured the answer out my self. I wish I would have found it sooner.

Here is what I came up with

Case $QuestA = "combat" 

  GUISetState(@SW_HIDE,$MainGUI)

  GUISetState(@SW_HIDE,$CharactersetupGUI)

  GUISetState(@SW_SHOW,$CombatGUI)

  $Newcount = IniRead ("Character.ini", "Counter", "count", "0" ) + 1

        Iniwrite ( "Character.ini", "Counter", "count", $Newcount )

  $Count = IniRead ("Character.ini", "Counter", "count", "0" )

  $QuestA = IniRead ("Quest.ini", "QuestA",$Count,"error")

  GUICtrlSetData($Questlabel,$QuestA);CHANGES THE DATA IN THE LABEL TO $QuestA

Case $QuestB = "combat" 

  GUISetState(@SW_HIDE,$MainGUI)

  GUISetState(@SW_HIDE,$CharactersetupGUI)

  GUISetState(@SW_SHOW,$CombatGUI)

  $Newcount = IniRead ("Character.ini", "Counter", "count", "0" ) + 1

        Iniwrite ( "Character.ini", "Counter", "count", $Newcount )

  $Count = IniRead ("Character.ini", "Counter", "count", "0" )

  $QuestB = IniRead ("Quest.ini", "QuestB",$Count,"error")

  GUICtrlSetData($Questlabel,$QuestB);CHANGES THE DATA IN THE LABEL TO $QuestB

    Case $QuestC = "combat" 

  GUISetState(@SW_HIDE,$MainGUI)

  GUISetState(@SW_HIDE,$CharactersetupGUI)

  GUISetState(@SW_SHOW,$CombatGUI)

  $Newcount = IniRead ("Character.ini", "Counter", "count", "0" ) + 1

        Iniwrite ( "Character.ini", "Counter", "count", $Newcount )

  $Count = IniRead ("Character.ini", "Counter", "count", "0" )

  $QuestC = IniRead ("Quest.ini", "QuestC",$Count,"error")

  GUICtrlSetData($Questlabel,$QuestC);CHANGES THE DATA IN THE LABEL TO $QuestC

and it fixed the problem and read the next line in the line in the questlabel after I got back to the main gui. thank you for replying. You have been very helpfull.

.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...