5 Replies - 277 Views - Last Post: 22 October 2013 - 08:32 AM Rate Topic: -----

#1 huntersshadow  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 22-October 13

connecting options to a windows form "button" and "dialog&

Posted 22 October 2013 - 06:53 AM

so im trying to put my options i gave the player for my text adventure into 3 buttons, mainly two, also in a windows form file but i really have no clue how to put the "cases" into buttons, along with the dialog.

 static void Main(string[] args)
        {
            
            Console.ForegroundColor = ConsoleColor.Gray;
            System.Console.WriteLine("                                ~text adventure~");
            System.Console.WriteLine();
            game_Start();
            Console.ReadKey();
        }
        static void death()
        {
            Console.ResetColor();
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("                                    YOU DIED");
            Console.ResetColor();
            game_Start();
        }
        static void game_Start()
        {
            int menu_choice;
            Console.WriteLine("-------------------------------------------------------------------------------");
            System.Console.WriteLine("choose: ");
            Console.WriteLine("-------------------------------------------------------------------------------");
            Console.ResetColor();
            Console.BackgroundColor = ConsoleColor.Gray;
            Console.ForegroundColor = ConsoleColor.Red;
            System.Console.WriteLine("1: play");
            System.Console.WriteLine("2: info");
            System.Console.WriteLine("3: exit");
            Console.ResetColor();
            menu_choice = int.Parse(System.Console.ReadLine());
            switch (menu_choice)
            {
                case 1:
                    adventure_start();
                    break;
                case 2:
                    Console.WriteLine("-------------------------------------------------------------------------------");
                    Console.WriteLine("Made by hunter");
                    Console.WriteLine("-------------------------------------------------------------------------------");
                    game_Start();
                    break;
                case 3:
                    return;

                default:
                    Console.WriteLine("-------------------------------------------------------------------------------");
                    System.Console.WriteLine("Not an option.");
                    System.Console.WriteLine("Enter.");
                    System.Console.ReadLine();
                    Console.WriteLine("-------------------------------------------------------------------------------");
                    game_Start();
                    break;
            }


Is This A Good Question/Topic? 0
  • +

Replies To: connecting options to a windows form "button" and "dialog&

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8897
  • View blog
  • Posts: 33,369
  • Joined: 12-June 08

Re: connecting options to a windows form "button" and "dialog&

Posted 22 October 2013 - 06:58 AM

Quote

so im trying to put my options i gave the player for my text adventure into 3 buttons

Care to explain this?
Was This Post Helpful? 0
  • +
  • -

#3 huntersshadow  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 22-October 13

Re: connecting options to a windows form "button" and "dialog&

Posted 22 October 2013 - 07:00 AM

where i give them the options i want to put those options into buttons so on the form all they need to do is click the button called "Option 1" and it chooses that option.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8897
  • View blog
  • Posts: 33,369
  • Joined: 12-June 08

Re: connecting options to a windows form "button" and "dialog&

Posted 22 October 2013 - 07:11 AM

Okay dokey.. you are sort of already doing event programming (or at least user-reacted programming) with your code above.. now just think a bit more globally.

Have a method that sets up you game environment..
have your three buttons and their click events ready.
Have a method that takes in a number (for the menu choice), and - more or less - does your switch statement.
In each button click event have it call the method mentioned and for the incoming parameter feed it the appropriate menu number.
Was This Post Helpful? 1
  • +
  • -

#5 huntersshadow  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 22-October 13

Re: connecting options to a windows form "button" and "dialog&

Posted 22 October 2013 - 07:27 AM

alright ill try that out and let you know how it goes

im having a bit of trouble connecting the "click event" to my "menu_choice"
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8897
  • View blog
  • Posts: 33,369
  • Joined: 12-June 08

Re: connecting options to a windows form "button" and "dialog&

Posted 22 October 2013 - 08:32 AM

In the GUI designer click on the button. In the properties pane there's a little lightening bolt.. click on that.. you can now scroll through all the possible events for that UI object. Find 'click' and just double click on the the name 'click'. It should set one up for you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1