Editing Storing MFD Instances
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
− | In Orbiter, if you switch focus to another vessel, or switch camera modes, the [[MFD]]s that are open get deleted. This is because [[MFD]]s are strictly designed for displaying data. But what if you were writing an [[MFD]] that needed to cache data? For example, a user defined value. Every time the user switches focus, or camera modes, the [[MFD]] will get destroyed. This article shows how you can bypass this problem | + | In Orbiter, if you switch focus to another vessel, or switch camera modes, the [[MFD]]s that are open get deleted. This is because [[MFD]]s are strictly designed for displaying data. But what if you were writing an [[MFD]] that needed to cache data? For example, a user defined value. Every time the user switches focus, or camera modes, the [[MFD]] will get destroyed. This article shows how you can bypass this problem. |
== Basic Plan == | == Basic Plan == | ||
Line 58: | Line 58: | ||
{ | { | ||
// match found! | // match found! | ||
− | if (g_data | + | if (g_data[i]->hook==vessel->GetHandle()) |
{ | { | ||
// cache the pointer | // cache the pointer | ||
− | this->data=g_data | + | this->data=g_data[i]; |
found=true; | found=true; | ||
break; | break; | ||
Line 103: | Line 103: | ||
{ | { | ||
it = g_data.begin() + i; | it = g_data.begin() + i; | ||
− | if (!oapiIsVessel(g_data | + | if (!oapiIsVessel(g_data[i]->hook)) // if vessel does not exist, delete the vector |
{ | { | ||
− | delete g_data | + | delete g_data[i]; |
g_data.erase(it); | g_data.erase(it); | ||
} | } | ||
Line 112: | Line 112: | ||
</pre> | </pre> | ||
− | |||
− | |||
− | + | [[Category:Addon tutorials]][[Category:Tutorials]] | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | [[Category: | ||
− | [[Category:Tutorials | ||
− | |||
− |