void CUISequenceItem::Load(CUIXml* xml, int idx) { XML_NODE* _stored_root = xml->GetLocalRoot(); xml->SetLocalRoot (xml->NavigateToNode("item",idx)); int disabled_cnt = xml->GetNodesNum (xml->GetLocalRoot(), "disabled_key"); for(int i=0; i<disabled_cnt;++i){ LPCSTR str = xml->Read ("disabled_key", i, NULL); m_disabled_actions.push_back( action_name_to_id(str) ); }; LPCSTR str; bool functor_exists; int j; int f_num = xml->GetNodesNum(xml->GetLocalRoot(),"function_on_start"); m_start_lua_functions.resize (f_num); for(j=0; j<f_num; ++j){ str = xml->Read(xml->GetLocalRoot(), "function_on_start", j, NULL); functor_exists = ai().script_engine().functor(str ,m_start_lua_functions[j]); THROW3 (functor_exists, "Cannot find script function described in tutorial item ", str); } f_num = xml->GetNodesNum(xml->GetLocalRoot(),"function_on_stop"); m_stop_lua_functions.resize (f_num); for(j=0; j<f_num; ++j){ str = xml->Read(xml->GetLocalRoot(), "function_on_stop", j, NULL); functor_exists = ai().script_engine().functor(str ,m_stop_lua_functions[j]); THROW3 (functor_exists, "Cannot find script function described in tutorial item ", str); } xml->SetLocalRoot (_stored_root); }
virtual void Execute(LPCSTR args) { int action_id = action_name_to_id (args); _binding* pbinding = &g_key_bindings[action_id]; pbinding->m_keyboard[m_work_idx] = NULL; CStringTable::ReparseKeyBindings(); }
virtual void Execute(LPCSTR args) { string256 action; string256 key; *action = 0; *key = 0; sscanf (args,"%s %s", action, key); if (!*action) return; if (!*key) return; if(!bRemapped) { remap_keys (); bRemapped = TRUE; } if (!action_name_to_ptr(action)) return; int action_id = action_name_to_id (action); if (action_id==kNOTBINDED) return; _keyboard* pkeyboard = keyname_to_ptr(key); if (!pkeyboard) return; _binding* curr_pbinding = &g_key_bindings[action_id]; curr_pbinding->m_keyboard[m_work_idx]= pkeyboard; { for(int idx=0; idx<bindings_count; ++idx) { _binding* binding = &g_key_bindings[idx]; if(binding==curr_pbinding) continue; bool b_conflict = !is_group_not_conflicted(binding->m_action->key_group, curr_pbinding->m_action->key_group); if(binding->m_keyboard[0]==pkeyboard && b_conflict) binding->m_keyboard[0]=NULL; if(binding->m_keyboard[1]==pkeyboard && b_conflict) binding->m_keyboard[1]=NULL; } } CStringTable::ReparseKeyBindings(); }
void GetActionAllBinding (LPCSTR _action, char* dst_buff) { int action_id = action_name_to_id(_action); _binding* pbinding = &g_key_bindings[action_id]; string16 prim; string16 sec; prim[0] = 0; sec[0] = 0; if(pbinding->m_keyboard[0]) { strcpy(prim, pbinding->m_keyboard[0]->key_local_name.c_str()); } if(pbinding->m_keyboard[1]) { strcpy(sec, pbinding->m_keyboard[1]->key_local_name.c_str()); } sprintf (dst_buff,"%s%s%s", prim[0]?prim:"", (sec[0]&&prim[0])?" , ":"", sec[0]?sec:""); }
void CUISequenceSimpleItem::Load(CUIXml* xml, int idx) { CUISequenceItem::Load (xml,idx); XML_NODE* _stored_root = xml->GetLocalRoot(); xml->SetLocalRoot (xml->NavigateToNode("item",idx)); LPCSTR m_snd_name = xml->Read ("sound",0,"" ); if (m_snd_name&&m_snd_name[0]){ m_sound.create (m_snd_name,st_Effect,sg_Undefined); VERIFY (m_sound._handle()); } m_time_length = xml->ReadFlt ("length_sec",0,0 ); m_desired_cursor_pos.x = xml->ReadAttribFlt ("cursor_pos",0,"x",1024); m_desired_cursor_pos.y = xml->ReadAttribFlt ("cursor_pos",0,"y",768 ); strcpy (m_pda_section, xml->Read("pda_section",0,"") ); LPCSTR str = xml->Read ("pause_state",0,"ignore"); m_flags.set (etiNeedPauseOn, 0==_stricmp(str, "on")); m_flags.set (etiNeedPauseOff, 0==_stricmp(str, "off")); LPCSTR str2 = xml->Read ("pause_sound",0,"ignore"); m_flags.set (etiNeedPauseSound, 0==_stricmp(str2, "on")); str = xml->Read ("guard_key",0,NULL ); m_continue_dik_guard = -1; if (str && !_stricmp(str,"any")){ m_continue_dik_guard = 9999; str = NULL; } if(str){ EGameActions cmd = action_name_to_id (str); m_continue_dik_guard = get_action_dik (cmd); } m_flags.set (etiCanBeStopped, (m_continue_dik_guard==-1)); m_flags.set (etiGrabInput, 1==xml->ReadInt("grab_input",0,1)); //ui-components m_UIWindow = xr_new<CUIWindow>(); m_UIWindow->SetAutoDelete (false); XML_NODE* _lsr = xml->GetLocalRoot(); CUIXmlInit xml_init; xml_init.InitWindow (*xml, "main_wnd", 0, m_UIWindow); //. xml_init.InitAutoStaticGroup (*xml, "main_wnd", m_UIWindow); xml->SetLocalRoot (_lsr); // initialize auto_static int cnt = xml->GetNodesNum ("main_wnd",0,"auto_static"); m_subitems.resize (cnt); string64 sname; for(int i=0;i<cnt;++i){ XML_NODE* _sr = xml->GetLocalRoot(); xml->SetLocalRoot (xml->NavigateToNode("main_wnd",0)); sprintf_s (sname,"auto_static_%d", i); SSubItem* _si = &m_subitems[i]; _si->m_start = xml->ReadAttribFlt("auto_static",i,"start_time",0); _si->m_length = xml->ReadAttribFlt("auto_static",i,"length_sec",0); _si->m_visible = false; _si->m_wnd = smart_cast<CUIStatic*>(find_child_window(m_UIWindow, sname)); VERIFY(_si->m_wnd); _si->m_wnd->SetTextComplexMode(true); _si->m_wnd->Show (false); xml->SetLocalRoot (_sr); } xml->SetLocalRoot (_stored_root); }
void CUISequenceSimpleItem::Load(CUIXml* xml, int idx) { CUISequenceItem::Load (xml,idx); XML_NODE* _stored_root = xml->GetLocalRoot(); xml->SetLocalRoot (xml->NavigateToNode("item",idx)); LPCSTR m_snd_name = xml->Read ("sound",0,"" ); if (m_snd_name&&m_snd_name[0]){ m_sound.create (m_snd_name,st_Effect,sg_Undefined); VERIFY (m_sound._handle() || strstr(Core.Params,"-nosound")); } m_time_length = xml->ReadFlt ("length_sec",0,0 ); m_desired_cursor_pos.x = xml->ReadAttribFlt ("cursor_pos",0,"x",0); m_desired_cursor_pos.y = xml->ReadAttribFlt ("cursor_pos",0,"y",0 ); xr_strcpy (m_pda_section, xml->Read("pda_section",0,"") ); LPCSTR str = xml->Read ("pause_state", 0,"ignore"); m_flags.set (etiNeedPauseOn, 0==_stricmp(str, "on")); m_flags.set (etiNeedPauseOff, 0==_stricmp(str, "off")); m_flags.set (etiNeedPauseSound, 0==_stricmp(str, "on")); str = xml->Read ("guard_key",0,NULL ); m_continue_dik_guard = -1; if (str && !_stricmp(str,"any")){ m_continue_dik_guard = 9999; str = NULL; } if(str){ EGameActions cmd = action_name_to_id (str); m_continue_dik_guard = get_action_dik (cmd); } m_flags.set (etiCanBeStopped, (m_continue_dik_guard==-1)); LPCSTR str_grab_input = xml->Read("grab_input",0,"on"); m_flags.set (etiGrabInput, (0==_stricmp(str_grab_input, "on")||0==_stricmp(str_grab_input, "1")) ); int actions_count = xml->GetNodesNum (0,0,"action"); m_actions.resize (actions_count); for(int idx=0; idx<actions_count; ++idx) { SActionItem& itm = m_actions[idx]; LPCSTR str = xml->ReadAttrib("action", idx, "id"); itm.m_action = action_name_to_id(str); itm.m_bfinalize = !!xml->ReadAttribInt("action", idx, "finalize", FALSE); itm.m_functor = xml->Read(xml->GetLocalRoot(), "action", idx, ""); } //ui-components m_UIWindow = xr_new<CUIWindow>(); m_UIWindow->SetAutoDelete (false); XML_NODE* _lsr = xml->GetLocalRoot(); CUIXmlInit xml_init; xml_init.InitWindow (*xml, "main_wnd", 0, m_UIWindow); xml->SetLocalRoot (_lsr); // initialize auto_static int cnt = xml->GetNodesNum ("main_wnd", 0, "auto_static"); m_subitems.resize (cnt); string64 sname; for(int i=0;i<cnt;++i) { XML_NODE* _sr = xml->GetLocalRoot(); xml->SetLocalRoot (xml->NavigateToNode("main_wnd", 0)); xr_sprintf (sname, "auto_static_%d", i); SSubItem* _si = &m_subitems[i]; _si->m_start = xml->ReadAttribFlt("auto_static", i, "start_time", 0); _si->m_length = xml->ReadAttribFlt("auto_static", i, "length_sec", 0); _si->m_visible = false; _si->m_wnd = smart_cast<CUIStatic*>(find_child_window(m_UIWindow, sname)); VERIFY (_si->m_wnd); _si->m_wnd->TextItemControl()->SetTextComplexMode(true); _si->m_wnd->Show (false); _si->m_wnd->SetWidth (_si->m_wnd->GetWidth()*UI().get_current_kx()); if(UI().is_widescreen()) { XML_NODE* autostatic_node = xml->NavigateToNode("auto_static", i); XML_NODE* ws_rect = xml->NavigateToNode(autostatic_node, "widescreen_rect", 0); if(ws_rect) { xml->SetLocalRoot (autostatic_node); Fvector2 pos, size; pos.x = xml->ReadAttribFlt("widescreen_rect", 0, "x"); pos.y = xml->ReadAttribFlt("widescreen_rect", 0, "y"); size.x = xml->ReadAttribFlt("widescreen_rect", 0, "width"); size.y = xml->ReadAttribFlt("widescreen_rect", 0, "height"); _si->m_wnd->SetWndPos (pos); _si->m_wnd->SetWndSize (size); } } xml->SetLocalRoot (_sr); } xml->SetLocalRoot (_stored_root); }