Commit 9c3f6577 authored by 柯南's avatar 柯南 Committed by Gitee

GetListBoxIndex

parent d69823b9
...@@ -9,6 +9,16 @@ bool exit_on_return = false; ...@@ -9,6 +9,16 @@ bool exit_on_return = false;
bool bot_mode = false; bool bot_mode = false;
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
int GetListBoxIndex(IGUIListBox* listbox, const wchar_t* target){
int count = listbox->getItemCount();
for(int i = 0; i < count; i++){
auto item = listbox->getListItem(i);
if(wcscmp(item, target)){
return i;
}
}
return 0;
}
void android_main(ANDROID_APP app) { void android_main(ANDROID_APP app) {
app->inputPollSource.process = android::process_input; app->inputPollSource.process = android::process_input;
app_dummy(); app_dummy();
...@@ -59,22 +69,21 @@ int main(int argc, char* argv[]) { ...@@ -59,22 +69,21 @@ int main(int argc, char* argv[]) {
ygo::mainGame->device->postEventFromUser(event); ygo::mainGame->device->postEventFromUser(event);
break; break;
} else if(!strcmp(arg, "-r")) { // Replay } else if(!strcmp(arg, "-r")) { // Replay
char* name = NULL; int index = 0;
if((i+1) < argc){//下一个参数是录像名 if((i+1) < argc){//下一个参数是录像名
#ifdef _IRR_ANDROID_PLATFORM_ #ifdef _IRR_ANDROID_PLATFORM_
name = argv[i+1].c_str(); char* name = argv[i+1].c_str();
#else #else
name = argv[i+1]; char* name = argv[i+1];
#endif #endif
wchar_t fname[1024];
BufferIO::DecodeUTF8(name, fname);
index = GetListBoxIndex(ygo::mainGame->lstReplayList, fname);
} }
event.GUIEvent.Caller = ygo::mainGame->btnReplayMode; event.GUIEvent.Caller = ygo::mainGame->btnReplayMode;
ygo::mainGame->device->postEventFromUser(event); ygo::mainGame->device->postEventFromUser(event);
if(name != NULL){ ygo::mainGame->lstReplayList->setSelected(index);
//TODO may be error?
ygo::mainGame->lstReplayList->setSelected(name);
} else {
ygo::mainGame->lstReplayList->setSelected(0);
}
event.GUIEvent.Caller = ygo::mainGame->btnLoadReplay; event.GUIEvent.Caller = ygo::mainGame->btnLoadReplay;
ygo::mainGame->device->postEventFromUser(event); ygo::mainGame->device->postEventFromUser(event);
break;//只播放一个 break;//只播放一个
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment