MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / SetCurrentValue

Method SetCurrentValue

Descent3/ConfigItem.cpp:332–392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

330}
331
332bool ConfigItem::SetCurrentValue(int currvalue, bool call_back) {
333 if (!m_bAlive)
334 return false;
335 if (m_iValueType != CIV_INT)
336 return false;
337
338 float f_cv = (float)currvalue;
339 int i_cv = currvalue;
340
341 // do some error checking
342 switch (m_iType) {
343 case CIT_HOTSPOTLIST:
344 case CIT_RADIOBUTTON:
345 if (i_cv < 0)
346 i_cv = 0;
347 if (i_cv >= m_iNumIDs)
348 i_cv = m_iNumIDs - 1;
349 break;
350 case CIT_SLIDER:
351 if (f_cv < m_fMin)
352 f_cv = m_fMin;
353 if (f_cv >= m_fMax)
354 f_cv = m_fMax;
355 i_cv = (int)(((float)(f_cv - m_fMin)) / m_fUnit);
356 break;
357 case CIT_LISTBOX:
358 // handles error checking in itself
359 break;
360 case CIT_CHECKBOX:
361 case CIT_ONOFFBUTTON:
362 case CIT_YESNOBUTTON:
363 Int3();
364 break;
365 }
366
367 switch (m_iType) {
368 case CIT_HOTSPOTLIST:
369 case CIT_RADIOBUTTON:
370 m_rbList[i_cv]->Activate();
371 break;
372 case CIT_SLIDER:
373 m_sList[0]->SetPos(i_cv);
374 UpdateSlider(0, call_back);
375 break;
376 case CIT_LISTBOX:
377 m_lbList[0]->SetSelectedIndex(i_cv);
378 break;
379 case CIT_CHECKBOX:
380 case CIT_ONOFFBUTTON:
381 case CIT_YESNOBUTTON:
382 Int3();
383 break;
384 }
385
386 // set the value than update
387 m_iCurrentValue = currvalue;
388
389 // Update(int result);

Callers

nothing calls this directly

Calls 5

SetStatesMethod · 0.80
ActivateMethod · 0.45
SetPosMethod · 0.45
SetSelectedIndexMethod · 0.45
SetTitleMethod · 0.45

Tested by

no test coverage detected