Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Some questions about Visual C++, arrays and map.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Sat Aug 27, 2016 12:37 am    Post subject: Some questions about Visual C++, arrays and map. Reply with quote

I want to make a form like the one on the screenshot. When the user selects a name in the comboBox, three values, which are attack, defense, intelligence, will appear in the three textBoxes on the right. I do not want to use "comboBox->SelectedIndex" instead of "comboBox->Text".

Therefore, here is my plan:
1. Use map in C++ to associate each names(string) with an integer. For example, Michael with 0, James with 2, Bob with 1(different than the order that appears on the comboBox drop down list) :
Code:

std::map<std::string, int> players;
players["Michael"] = 0;
players["Bob"] = 1;
players["James"] = 2;




2. Create an array to store the three values with the names. For example,
Code:

int data[][2] ={
      {15, 15, 15}, //Michael
      {30, 25, 5}, //Bob
      {10, 10, 30}, //James
      ....................
}


3. Check the text in the comboBox, then get the corresponding values:
Code:

   //The combobox selection change event:
   textBox1->Text == data[players[comboBox1->Text]][0]; //attack
   textBox2->Text == data[players[comboBox1->Text]][1];//defense
   textBox3->Text == data[players[comboBox1->Text]][2];//intelligence



So, my questions are:
1. Will this work?
2. If so, where should I declare and define the array and map? I had run into some problems with this issue. I was using C++ window form on Visual Studio 2015. All the events are automatically generated in the header file. I declared and defined the map and array in the form class, but they could not be used in the event function, like they were not activated.

I hope my explanation is not very confusing. Sad

Thanks in advance.



Capture.JPG
 Description:
 Filesize:  19.44 KB
 Viewed:  3166 Time(s)

Capture.JPG


Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites