G_MODULE_EXPORT void on_treeview2_cursor_changed (GtkTreeView *treeview, gpointer user_data) { change_selection(2, treeview); }
void WeaponEditorDlg::OnClose() { UpdateData(TRUE); UpdateData(TRUE); change_selection(); update_pilot(); CDialog::OnClose(); }
void WeaponEditorDlg::OnSelchangeMissile6() { UpdateData(TRUE); UpdateData(TRUE); m_ammo_max6 = get_max_ammo_count_for_bank(m_ship_class, 5, m_missile6 + First_secondary_index - 1); m_ammo6 = m_ammo_max6 ? (m_ammo_max6) : 0; change_selection(); }
G_MODULE_EXPORT void on_treeview3_cursor_changed (GtkTreeView *treeview, gpointer user_data) { change_selection(3, treeview); (void) &id; // avoid warning "id defined but not used" }
void EditorMapData::add_particle(const ParticleData &particle, const SelectionChangeType selection) { m_particles.insert(std::pair<Uint32, ParticleData>(particle.get_id(), particle)); // m_scene->add_particle(particle); change_selection(particle.get_id(), rt_particle, selection); }
void EditorMapData::add_light(const LightData &light, const SelectionChangeType selection) { m_lights.insert(std::pair<Uint32, LightData>(light.get_id(), light)); m_scene->add_light(light); change_selection(light.get_id(), rt_light, selection); }
void WeaponEditorDlg::OnSelchangeMissile4() { UpdateData(TRUE); UpdateData(TRUE); if (m_cur_item == 0) { m_ammo_max4 = get_max_ammo_count_for_bank(m_ship_class, 3, m_missile4 + First_secondary_index - 1); } else { m_ammo_max4 = get_max_ammo_count_for_turret_bank(cur_weapon, 3, m_missile4 + First_secondary_index - 1); } m_ammo4 = m_ammo_max4 ? (m_ammo_max4) : 0; change_selection(); }
void EditorMapData::add_object( const EditorObjectDescription &object_description, const SelectionChangeType selection) { m_objects.insert(std::pair<Uint32, EditorObjectDescription>(object_description.get_id(), object_description)); m_scene->add_object(object_description); change_selection(object_description.get_id(), rt_object, selection); }
void pvs_check_hint(int selection) { int nr,vnr; unsigned long uvnr=0; Char *hintstr; PVSProof *pvsproof; ProofStep **cstep; char *head; int assumptions=0; int np=0; int curlinenr=0; FILE *f; char buffer[1024]; /* check if hint is selected */ nr = selected_notation(selection, &vnr); if (nr>=0) uvnr = which_notation(nnr_vnr2innr(nr,0))->vers[vnr].vnr; if (nr<0 || uvnr<firsthintnr || uvnr> lasthintnr) { message(MP_ERROR, translate("No valid hint selected")); return; } pvsproof=pvs_temporary_file(lasthintfile, &f); { int pos[2]; copy_selection(&pvsproof->selection, get_selection(selection)); pos[0]=1;pos[1]=0; change_selection(pvsproof->selection, pos,2); } { char lemmabuf[500]; sprintf(lemmabuf, "%s%i", UstrtoLocale(pvs_lemma_name), lastlemmanr); lastlemmanr++; pvsproof->lemma = strdup(lemmabuf); fprintf(f,"%s: THEOREM\n\t\t", lemmabuf); curlinenr++; } assumptions=0; cstep = &pvsproof->step; /* add an empty proof step to store the starting expression */ *cstep = malloc(sizeof(ProofStep)); (*cstep)->next=0; (*cstep)->keyword=0; (*cstep)->pvsinput=0; (*cstep)->comment=translate("starting formula"); (*cstep)->result=0; (*cstep)->failed=0; (*cstep)->steptype=SkipStep; (*cstep)->use_result=0; cstep = &((*cstep)->next); /* add the initial proof step to start the hints */ *cstep = malloc(sizeof(ProofStep)); (*cstep)->next=0; (*cstep)->keyword=get_pvskeyword(translate("INITSTEP")); (*cstep)->pvsinput=0; (*cstep)->comment=translate("initialisation steps"); (*cstep)->result=0; (*cstep)->failed=0; (*cstep)->use_result=0; (*cstep)->steptype=InitStep; cstep = &((*cstep)->next); /* parse text in hint: ** - expression -> add to assumptions ** - "induction" -> add 'Ef = El' to assumptions ** (Ef: first expr., El: last expr, =: weakest operator) ** add (inst?)(ground)(try-triv-step (replace*)) to proof ** - "name" -> add (modulo-assoc (bidi-rewrite "name")) to proof ** - "definition" -> add (expand-simp* "def1" ... "defn") to proof ** (def1 ... defn extracted from expressions) ** - hidden PVS -> add content to proof */ { int pos[2]; pos[0]=1; pos[1]=0; hintstr = get_subnode_string(selection, pos,2); } if (!hintstr || !hintstr[0]) { /* empty hints usually indicate trivial steps */ hintstr = translate("trivial"); } while (*hintstr) { if (IsPh(hintstr[0])) { /* An expression, identifier, operator of text */ void *node; int pos[3]; char *str=0; pos[0]=1; pos[1]=0; pos[2]=np++; node = get_subnode(selection, pos, 3); nr = node_notation(node, &vnr); if (nr!= -1) uvnr = which_notation(nnr_vnr2innr(nr,0))->vers[0].vnr; tex_set_string(&str); tex_placeholders(0); latex_all_parens(MP_True); tex_mode(ASCII); latex_node(node); tex_unset(); latex_all_parens(MP_False); if (str && str[0]) { /* the expression produces output */ if (uvnr==pvshiddenstep) { /* a special PVS related template to add steps to the proof list */ *cstep = malloc(sizeof(ProofStep)); (*cstep)->next=0; (*cstep)->keyword=0; (*cstep)->pvsinput=str; (*cstep)->comment=translate("hidden proof steps"); (*cstep)->result=0; (*cstep)->failed=0; (*cstep)->use_result=0; (*cstep)->steptype=HiddenStep; cstep = &((*cstep)->next); } else { /* A normal expression. For now, an assumption, but it could be ** an identifier (as in "definition of $fold$") or ** a single operator (as in "$\times$ distributes over $\plus$") */ if (!assumptions) { fprintf(f,"(\t"); } else { fprintf(f,"\t\t AND "); } fprintf(f, "%s\n",str); curlinenr++; { char *h; for (h=str; *h; h++) { if (*h=='\n') curlinenr++; } } free(str); assumptions++; *cstep = malloc(sizeof(ProofStep)); (*cstep)->next=0; (*cstep)->keyword=get_pvskeyword(translate("EXPRESSIONSTEP")); (*cstep)->pvsinput=0; (*cstep)->comment=translate("assumption step"); (*cstep)->result=0; (*cstep)->failed=0; (*cstep)->use_result=0; (*cstep)->steptype=ExpressionStep; cstep = &((*cstep)->next); } } hintstr++; } else { KeywordItem *kwi= kwlist; kwi = get_pvskeyword(hintstr); if (kwi) { if (kwi->induct) { void *node; char *str=0; char *h; tex_set_string(&str); tex_placeholders(0); latex_all_parens(MP_True); tex_mode(ASCII); node = first_node(get_selection(selection)); latex_node(node); out_latex_char('='); node = last_node(get_selection(selection)); latex_node(node); tex_unset(); latex_all_parens(MP_False); /* ** Filter out '+(1)' and '+1'. ** This should be adjusted for allow induction on other types */ h=str; while (h && ((h=strstr(h,"+(1)")))) { int i; for (i=0; i<4;i++) h[i]=' '; h=h+4; } h=str; while (h && ((h=strstr(h,"+1")))) { int i; for (i=0; i<2;i++) h[i]=' '; h=h+2; } if (!assumptions) { fprintf(f,"(\t"); } else { fprintf(f,"\t\t AND "); } fprintf(f, "%s\n",str); curlinenr++; { char *nlc; for (nlc=str; *nlc; nlc++) { if (*nlc=='\n') curlinenr++; } } free(str); assumptions++; } if (kwi->step && kwi->step[0]) { *cstep = malloc(sizeof(ProofStep)); (*cstep)->next=0; (*cstep)->keyword=kwi; (*cstep)->pvsinput=0; (*cstep)->comment=0; (*cstep)->result=0; (*cstep)->failed=0; (*cstep)->use_result=0; (*cstep)->steptype=KeywordStep; cstep = &((*cstep)->next); } hintstr=hintstr+kwi->len; } /* might want to skip to the next place holder/word boundary */ hintstr++; } } if (assumptions) { fprintf(f,"\t\t) IMPLIES\n\t\t\t"); curlinenr++; } /* generate lemma */ { char *str=0; tex_set_string(&str); tex_placeholders(0); latex_all_parens(MP_True); tex_mode(ASCII); latex_selection(selection); tex_unset(); latex_all_parens(MP_False); { char *nlc; for (nlc=str; *nlc; nlc++) if (*nlc=='\n') curlinenr++; } fprintf(f, "%s\n\n", str); curlinenr += 2; } *cstep = malloc(sizeof(ProofStep)); (*cstep)->next=0; (*cstep)->keyword=get_pvskeyword(translate("FINISHSTEP")); (*cstep)->pvsinput=0; (*cstep)->comment=0; (*cstep)->result=0; (*cstep)->failed=0; (*cstep)->use_result=0; (*cstep)->steptype=FinishStep; cstep = &((*cstep)->next); fprintf(f, "\nEND %s\n", pvsproof->theory); fclose(f); lasthintfile++; /* start PVS proof of temporary lemma */ pvs_start_proof(pvsproof); /* pvs_start_proof starts the proof of the selected hint(s) ** and checks if each step is correct, by sending the step, ** parse the output, check for errors, send next step, etc. ** At the end, Q.E.D. should appear and the ** delivery. */ if (pvsproof) { ProofStep *ps; for (ps=pvsproof->step; ps; ps=ps->next) { if (ps->pvsinput) { string_to_window(translate("PVS Generated Proof"), LocaletoUstr((unsigned char*)ps->pvsinput)); } else if (ps->keyword && ps->keyword->step) { string_to_window(translate("PVS Generated Proof"), LocaletoUstr((unsigned char*)ps->keyword->step)); } } } /* set PVS parse function correct */ }
void change_selection_down(ClickRecognizerRef recognizer, Window *window) { change_selection(1); }
void WeaponEditorDlg::OnSelchangeList() { UpdateData(TRUE); UpdateData(TRUE); change_selection(); }
BOOL WeaponEditorDlg::OnInitDialog() { int i, z, big = 1, end1, end2, inst, flag = 0; object *ptr; model_subsystem *psub; ship_subsys *ssl, *pss; CComboBox *box; CListBox *list; CDialog::OnInitDialog(); m_ship = cur_ship; if (m_ship == -1) m_ship = Objects[cur_object_index].instance; end1 = First_secondary_index; end2 = Num_weapon_types; list = (CListBox *) GetDlgItem(IDC_LIST); z = list->AddString("Pilot"); if (m_multi_edit) { list->SetItemDataPtr(z, &pilot); ptr = GET_FIRST(&obj_used_list); while (ptr != END_OF_LIST(&obj_used_list)) { if (((ptr->type == OBJ_SHIP) || (ptr->type == OBJ_START)) && (ptr->flags[Object::Object_Flags::Marked])) { inst = ptr->instance; if (!(Ship_info[Ships[inst].ship_info_index].is_big_or_huge())) big = 0; if (!flag) { pilot = Ships[inst].weapons; m_ship_class = Ships[inst].ship_info_index; flag = 1; } else { Assert(Ships[inst].ship_info_index == m_ship_class); if (pilot.ai_class != Ships[inst].weapons.ai_class) pilot.ai_class = BLANK_FIELD; for (i=0; i<MAX_SHIP_PRIMARY_BANKS; i++) if (pilot.primary_bank_weapons[i] != Ships[inst].weapons.primary_bank_weapons[i]) pilot.primary_bank_weapons[i] = BLANK_FIELD; for (i=0; i<MAX_SHIP_SECONDARY_BANKS; i++) { if (pilot.secondary_bank_weapons[i] != Ships[inst].weapons.secondary_bank_weapons[i]) pilot.secondary_bank_weapons[i] = BLANK_FIELD; if (pilot.secondary_bank_ammo[i] != Ships[inst].weapons.secondary_bank_ammo[i]) pilot.secondary_bank_ammo[i] = BLANK_FIELD; } } } ptr = GET_NEXT(ptr); } } else { if (!(Ship_info[Ships[m_ship].ship_info_index].is_big_or_huge())) big = 0; m_ship_class = Ships[m_ship].ship_info_index; list->SetItemDataPtr(z, &Ships[m_ship].weapons); ssl = &Ships[m_ship].subsys_list; for (pss = GET_FIRST(ssl); pss != END_OF_LIST(ssl); pss = GET_NEXT(pss)) { psub = pss->system_info; if (psub->type == SUBSYSTEM_TURRET) { z = list->AddString(psub->subobj_name); list->SetItemDataPtr(z, &pss->weapons); } } } box = (CComboBox *) GetDlgItem(IDC_AI_CLASS); for (i=0; i<Num_ai_classes; i++){ box->AddString(Ai_class_names[i]); } for (i=0; i<end1; i++){ if ((Weapon_info[i].wi_flags & WIF_CHILD) || (!big && (Weapon_info[i].wi_flags & WIF_BIG_ONLY))){ end1 = i; } } box = (CComboBox *) GetDlgItem(IDC_GUN1); box->AddString("None"); for (i=0; i<end1; i++){ box->AddString(Weapon_info[i].name); } box = (CComboBox *) GetDlgItem(IDC_GUN2); box->AddString("None"); for (i=0; i<end1; i++){ box->AddString(Weapon_info[i].name); } box = (CComboBox *) GetDlgItem(IDC_GUN3); box->AddString("None"); for (i=0; i<end1; i++){ box->AddString(Weapon_info[i].name); } for (i=First_secondary_index; i<end2; i++){ if ((Weapon_info[i].wi_flags & WIF_CHILD) || (!big && (Weapon_info[i].wi_flags & WIF_BIG_ONLY))){ end2 = i; } } box = (CComboBox *) GetDlgItem(IDC_MISSILE1); box->AddString("None"); for (i=First_secondary_index; i<end2; i++){ box->AddString(Weapon_info[i].name); } box = (CComboBox *) GetDlgItem(IDC_MISSILE2); box->AddString("None"); for (i=First_secondary_index; i<end2; i++){ box->AddString(Weapon_info[i].name); } box = (CComboBox *) GetDlgItem(IDC_MISSILE3); box->AddString("None"); for (i=First_secondary_index; i<end2; i++){ box->AddString(Weapon_info[i].name); } box = (CComboBox *) GetDlgItem(IDC_MISSILE4); box->AddString("None"); for (i=First_secondary_index; i<end2; i++){ box->AddString(Weapon_info[i].name); } m_cur_item = 0; UpdateData(FALSE); change_selection(); UpdateData(TRUE); return TRUE; }
bool FePresent::handle_event( FeInputMap::Command c ) { if ( reset_screen_saver() ) return true; switch( c ) { case FeInputMap::Down: change_selection( 1, false ); break; case FeInputMap::Up: change_selection( -1, false ); break; case FeInputMap::PageDown: change_selection( get_page_size(), false ); break; case FeInputMap::PageUp: change_selection( -get_page_size(), false ); break; case FeInputMap::RandomGame: { int ls = m_feSettings->get_filter_size( m_feSettings->get_current_filter_index() ); if ( ls > 0 ) { int step = rand() % ls; if ( step != 0 ) change_selection( step ); } } break; case FeInputMap::ToggleRotateRight: toggle_rotate( FeSettings::RotateRight ); break; case FeInputMap::ToggleFlip: toggle_rotate( FeSettings::RotateFlip ); break; case FeInputMap::ToggleRotateLeft: toggle_rotate( FeSettings::RotateLeft ); break; case FeInputMap::ToggleMovie: toggle_movie(); break; case FeInputMap::NextDisplay: case FeInputMap::PrevDisplay: if ( m_feSettings->navigate_display( ( c == FeInputMap::NextDisplay ) ? 1 : -1 ) ) load_layout(); else update_to_new_list( 0, true ); break; case FeInputMap::NextFilter: case FeInputMap::PrevFilter: { int offset = ( c == FeInputMap::NextFilter ) ? 1 : -1; if ( m_feSettings->navigate_filter( offset ) ) load_layout(); else update_to_new_list( offset ); } break; case FeInputMap::ToggleLayout: m_feSettings->toggle_layout(); load_layout(); break; case FeInputMap::PrevFavourite: case FeInputMap::NextFavourite: case FeInputMap::PrevLetter: case FeInputMap::NextLetter: { int step( 0 ); switch ( c ) { case FeInputMap::PrevFavourite: step = m_feSettings->get_prev_fav_offset(); break; case FeInputMap::NextFavourite: step = m_feSettings->get_next_fav_offset(); break; case FeInputMap::PrevLetter: step = m_feSettings->get_next_letter_offset( -1 ); break; case FeInputMap::NextLetter: step = m_feSettings->get_next_letter_offset( 1 ); break; default: break; } if ( step != 0 ) change_selection( step, false ); } break; case FeInputMap::ScreenSaver: load_screensaver(); break; case FeInputMap::Intro: if ( !load_intro() ) load_layout(); break; case FeInputMap::LAST_COMMAND: default: // Not handled by us, return false so calling function knows // return false; } return true; }
void FePresent::set_selection_index( int index ) { int new_offset = index - get_selection_index(); if ( new_offset != 0 ) change_selection( new_offset ); }