trekmdl.cpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852
  1. #include "pch.h"
  2. #include "mdl.h"
  3. #include "trekmdl.h"
  4. //#include "console.h"
  5. #ifndef MARKCU
  6. #include "consoledata.h"
  7. #endif
  8. //////////////////////////////////////////////////////////////////////////////
  9. //
  10. // SwitchValuePane
  11. //
  12. //////////////////////////////////////////////////////////////////////////////
  13. class SwitchValuePane : public ValuePane
  14. {
  15. protected:
  16. TMap<int, TRef<Pane> > m_mapPanes;
  17. TRef<Pane> m_pPaneCurrent;
  18. TRef<Pane> m_pPaneDefault;
  19. int m_nValueCurrent;
  20. void UpdateLayout()
  21. {
  22. DefaultUpdateLayout();
  23. }
  24. public:
  25. SwitchValuePane(Number* pvalue) :
  26. ValuePane(pvalue),
  27. m_pPaneDefault(NULL)
  28. {
  29. pvalue->Update();
  30. NeedLayout();
  31. NeedPaint();
  32. m_nValueCurrent = (int)Number::Cast(pvalue)->GetValue();
  33. }
  34. ZString GetFunctionName() { return "SwitchPane"; }
  35. void InsertPane(Pane* pPane, int nPaneID)
  36. {
  37. ZAssert(nPaneID != -1); // reserved
  38. m_mapPanes.Set(nPaneID, pPane);
  39. UpdatePane();
  40. }
  41. void SetDefaultPane(Pane* pPane)
  42. {
  43. m_pPaneDefault = pPane;
  44. UpdatePane();
  45. }
  46. private:
  47. void UpdatePane()
  48. {
  49. TRef<Pane> pPane;
  50. if (!m_mapPanes.Find(m_nValueCurrent, pPane))
  51. pPane = m_pPaneDefault;
  52. if (pPane != m_pPaneCurrent)
  53. {
  54. if (m_pPaneCurrent)
  55. RemoveChild(m_pPaneCurrent);
  56. if (pPane)
  57. InsertAtBottom(pPane);
  58. m_pPaneCurrent = pPane;
  59. }
  60. }
  61. void ChildChanged(Value* pvalue, Value* pvalueNew)
  62. {
  63. ZAssert(NULL == pvalueNew);
  64. ZAssert(GetChild(0) == pvalue);
  65. pvalue->Update();
  66. m_nValueCurrent = (int)Number::Cast(pvalue)->GetValue();
  67. UpdatePane();
  68. }
  69. };
  70. //////////////////////////////////////////////////////////////////////////////
  71. //
  72. // ImageValuePane
  73. //
  74. //////////////////////////////////////////////////////////////////////////////
  75. class ImageValuePane : public ValuePane
  76. {
  77. public:
  78. ImageValuePane(Image* pimage) :
  79. ValuePane(pimage)
  80. {
  81. }
  82. Image* GetImage() { return Image::Cast((Value*)GetChild(0)); }
  83. void SetImage(Image* pimage) { SetChild(0, pimage); }
  84. private:
  85. void ChildChanged(Value* pvalue, Value* pvalueNew)
  86. {
  87. Value::ChildChanged(pvalue, pvalueNew);
  88. NeedPaint();
  89. NeedLayout();
  90. }
  91. void UpdateLayout()
  92. {
  93. Update();
  94. InternalSetSize(
  95. WinPoint::Cast(GetImage()->GetBounds().GetRect().Size())
  96. );
  97. Pane::UpdateLayout();
  98. }
  99. void Paint(Surface* psurface)
  100. {
  101. psurface->BitBlt(WinPoint(0, 0), GetImage()->GetSurface());
  102. }
  103. };
  104. //////////////////////////////////////////////////////////////////////////////
  105. //
  106. // StringValuePane
  107. //
  108. //////////////////////////////////////////////////////////////////////////////
  109. class StringValuePane : public Value, public StringPane
  110. {
  111. protected:
  112. TRef<ColorValue> m_pcolor;
  113. public:
  114. StringValuePane(StringValue* pvalue, ColorValue* pcolor, IEngineFont* pfont, WinPoint ptSize,
  115. Justification justify) :
  116. Value(pvalue, pcolor),
  117. StringPane((pvalue->Update(), pvalue->GetValue()), pfont, ptSize, justify),
  118. m_pcolor(pcolor)
  119. {
  120. pcolor->Update();
  121. SetTextColor(pcolor->GetValue());
  122. StringPane::SetString(pvalue->GetValue());
  123. }
  124. StringValuePane(StringValue* pvalue, ColorValue* pcolor, IEngineFont* pfont) :
  125. Value(pvalue, pcolor),
  126. StringPane((pvalue->Update(), pvalue->GetValue()), pfont),
  127. m_pcolor(pcolor)
  128. {
  129. pcolor->Update();
  130. SetTextColor(pcolor->GetValue());
  131. StringPane::SetString(pvalue->GetValue());
  132. }
  133. ZString GetFunctionName() { return "StringPane"; }
  134. virtual void SetString(const ZString& str)
  135. {
  136. StringPane::SetString(str);
  137. SetChild(0, new StringValue(str));
  138. }
  139. private:
  140. void ChildChanged(Value* pvalue, Value* pvalueNew)
  141. {
  142. ZAssert(NULL == pvalueNew);
  143. pvalue->Update();
  144. if (pvalue == m_pcolor)
  145. {
  146. ZAssert(pvalue == GetChild(1));
  147. SetTextColor(m_pcolor->GetValue());
  148. }
  149. else
  150. {
  151. ZAssert(pvalue == GetChild(0));
  152. StringPane::SetString(StringValue::Cast(pvalue)->GetValue());
  153. }
  154. }
  155. };
  156. //////////////////////////////////////////////////////////////////////////////
  157. //
  158. // GaugeValuePane
  159. //
  160. //////////////////////////////////////////////////////////////////////////////
  161. class GaugeValuePane : public ValuePane
  162. {
  163. private:
  164. TRef<Surface> m_psurface;
  165. float m_minValue;
  166. float m_maxValue;
  167. int m_value;
  168. int m_valueOld;
  169. int m_valueFlash;
  170. float m_timeLastChange;
  171. Color m_colorFlash;
  172. Color m_colorEmpty;
  173. public:
  174. GaugeValuePane(Surface* psurface,
  175. Number* pnumber, Number* ptime,
  176. const Color& colorFlash,
  177. const Color& colorEmpty) :
  178. ValuePane(pnumber, ptime),
  179. m_psurface(psurface),
  180. m_colorFlash(colorFlash),
  181. m_colorEmpty(colorEmpty),
  182. m_minValue(0.0f),
  183. m_maxValue(1.0f),
  184. m_value(0),
  185. m_valueOld(0),
  186. m_valueFlash(0),
  187. m_timeLastChange(ptime->GetValue())
  188. {
  189. pnumber->Update();
  190. SetValue(pnumber->GetValue(), true);
  191. assert(m_psurface);
  192. assert(m_minValue < m_maxValue);
  193. InternalSetSize(m_psurface->GetSize());
  194. NeedPaint();
  195. }
  196. protected:
  197. void Paint(Surface* psurface)
  198. {
  199. if (m_value != 0) {
  200. psurface->BitBlt(
  201. WinPoint(0, 0),
  202. m_psurface,
  203. WinRect(0, 0, m_value, YSize())
  204. );
  205. }
  206. if (m_value < m_valueFlash) {
  207. psurface->FillRect(
  208. WinRect(
  209. m_value,
  210. 0,
  211. m_valueFlash,
  212. YSize()
  213. ),
  214. m_colorFlash
  215. );
  216. }
  217. }
  218. void SetValue(float v, bool fFlash)
  219. {
  220. m_value =
  221. (int)bound(
  222. (v - m_minValue) * ((float)XSize()) / (m_maxValue - m_minValue),
  223. 0.0f,
  224. (float)XSize()
  225. );
  226. }
  227. void Update(float time)
  228. {
  229. if (m_value != m_valueOld) {
  230. if (m_value < m_valueOld) {
  231. m_valueFlash = m_valueOld;
  232. } else {
  233. m_valueFlash = m_value;
  234. }
  235. m_timeLastChange = time;
  236. m_valueOld = m_value;
  237. NeedPaint();
  238. }
  239. if (m_value != m_valueFlash && time - m_timeLastChange > 0.25f) {
  240. m_valueFlash = m_value;
  241. NeedPaint();
  242. }
  243. }
  244. private:
  245. void ChildChanged(Value* pvalue, Value* pvalueNew)
  246. {
  247. ZAssert(NULL == pvalueNew);
  248. if (pvalue == GetChild(0)) // number changed
  249. {
  250. pvalue->Update();
  251. SetValue(Number::Cast(pvalue)->GetValue(), true);
  252. }
  253. else // time changed
  254. {
  255. ZAssert(GetChild(1) == pvalue);
  256. pvalue->Update();
  257. Update(Number::Cast(pvalue)->GetValue());
  258. }
  259. }
  260. };
  261. //////////////////////////////////////////////////////////////////////////////
  262. //
  263. // Factories
  264. //
  265. //////////////////////////////////////////////////////////////////////////////
  266. class SwitchPaneFactory : public IFunction
  267. {
  268. public:
  269. TRef<IObject> Apply(ObjectStack& stack)
  270. {
  271. TRef<Number> pnumber; CastTo(pnumber, (IObject*)stack.Pop());
  272. TRef<IObjectList> plist; CastTo(plist, (IObject*)stack.Pop());
  273. TRef<SwitchValuePane> ppane = new SwitchValuePane(pnumber);
  274. plist->GetFirst();
  275. while (plist->GetCurrent() != NULL) {
  276. IObjectPair* ppair; CastTo(ppair, plist->GetCurrent());
  277. TRef<Pane> ppaneChild; CastTo(ppaneChild, (Pane*)ppair->GetFirst());
  278. TRef<Number> pnumberChildID = Number::Cast(ppair->GetSecond());
  279. ppane->InsertPane(ppaneChild, (int)pnumberChildID->GetValue());
  280. plist->GetNext();
  281. }
  282. if (stack.GetCount() > 0) {
  283. TRef<Pane> ppaneDefault; CastTo(ppaneDefault, (Pane*)(IObject*)stack.Pop());
  284. ppane->SetDefaultPane(ppaneDefault);
  285. }
  286. return (Pane*)ppane;
  287. }
  288. };
  289. class StringPaneFactory : public IFunction
  290. {
  291. public:
  292. TRef<IObject> Apply(ObjectStack& stack)
  293. {
  294. TRef<StringValue> pstring; CastTo(pstring, (IObject*)stack.Pop());
  295. TRef<ColorValue> pcolor; CastTo(pcolor, (IObject*)stack.Pop());
  296. TRef<PointValue> ppointSize;
  297. WinPoint ptSize;
  298. if (stack.GetCount() > 0)
  299. {
  300. CastTo(ppointSize, (IObject*)stack.Pop());
  301. ptSize = WinPoint(
  302. (int)ppointSize->GetValue().X(),
  303. (int)ppointSize->GetValue().Y()
  304. );
  305. }
  306. Justification justification = JustifyLeft();
  307. if (stack.GetCount() > 0)
  308. {
  309. TRef<Number> pjustify = Number::Cast((IObject*)stack.Pop());
  310. justification.SetWord((DWORD)pjustify->GetValue());
  311. }
  312. TRef<IEngineFont> pfont = TrekResources::SmallFont();
  313. if (stack.GetCount() > 0)
  314. {
  315. TRef<FontValue> pfontLocal; CastTo(pfontLocal, (IObject*)stack.Pop());
  316. pfont = pfontLocal->GetValue();
  317. }
  318. bool bRightClip = false;
  319. if (stack.GetCount() > 0)
  320. bRightClip = GetBoolean((IObject*)stack.Pop());
  321. TRef<StringValuePane> ppane;
  322. if (ppointSize)
  323. {
  324. if (bRightClip)
  325. justification = JustifyLeftClipRight();
  326. ppane = new StringValuePane(pstring, pcolor, pfont, ptSize, justification);
  327. }
  328. else
  329. ppane = new StringValuePane(pstring, pcolor, pfont);
  330. return (Pane*)ppane;
  331. }
  332. };
  333. class GaugePaneFactory : public IFunction
  334. {
  335. public:
  336. TRef<IObject> Apply(ObjectStack& stack)
  337. {
  338. TRef<Image> pimage = Image::Cast((Value*)(IObject*)stack.Pop());
  339. TRef<Number> pnumber; CastTo(pnumber, (IObject*)stack.Pop());
  340. Color colorFlash = GetColor((IObject*)stack.Pop());
  341. Color colorEmpty = GetColor((IObject*)stack.Pop());
  342. TRef<GaugeValuePane> ppane =
  343. new GaugeValuePane(
  344. pimage->GetSurface(),
  345. pnumber,
  346. GetWindow()->GetTime(),
  347. colorFlash,
  348. colorEmpty
  349. );
  350. return (Pane*)ppane;
  351. }
  352. };
  353. //////////////////////////////////////////////////////////////////////////////
  354. //
  355. // ButtonPane
  356. //
  357. //////////////////////////////////////////////////////////////////////////////
  358. namespace
  359. {
  360. class SoundIDEventSink : public IEventSink, public IIntegerEventSink
  361. {
  362. private:
  363. SoundID m_soundId;
  364. public:
  365. SoundIDEventSink(SoundID soundId)
  366. {
  367. m_soundId = soundId;
  368. };
  369. bool OnEvent(IIntegerEventSource* pevent, int nCmd)
  370. {
  371. return OnEvent(pevent);
  372. }
  373. bool OnEvent(IEventSource* pevent)
  374. {
  375. GetWindow()->StartSound(m_soundId);
  376. // HACK: force the sound to start _now_
  377. // (some buttons cause events that take 1/5 of a second or so to
  378. // happen, and the delay in the sonic feedback for the mouse click
  379. // is annoying).
  380. GetWindow()->SoundEngineUpdate();
  381. return true;
  382. }
  383. };
  384. };
  385. TRef<ButtonPane> CreateTrekButton(
  386. ButtonFacePane* ppane,
  387. bool bToggle,
  388. SoundID soundClick,
  389. float repeatRate,
  390. float repeatDelay
  391. )
  392. {
  393. TRef<ButtonPane> pbutton = CreateButton(ppane, bToggle, repeatRate, repeatDelay);
  394. pbutton->GetMouseEnterWhileEnabledEventSource()->AddSink(new SoundIDEventSink(mouseoverSound));
  395. pbutton->GetEventSource()->AddSink(new SoundIDEventSink(soundClick));
  396. return pbutton;
  397. }
  398. TRef<ButtonPane> CreateTrekButton(
  399. Pane* ppaneUp,
  400. Pane* ppaneDown,
  401. bool bToggle,
  402. SoundID soundClick,
  403. float repeatRate,
  404. float repeatDelay
  405. )
  406. {
  407. TRef<ButtonPane> pbutton = CreateButton(ppaneUp, ppaneDown, bToggle, repeatRate, repeatDelay);
  408. pbutton->GetMouseEnterWhileEnabledEventSource()->AddSink(new SoundIDEventSink(mouseoverSound));
  409. pbutton->GetEventSource()->AddSink(new SoundIDEventSink(soundClick));
  410. return pbutton;
  411. }
  412. class ButtonPaneFactory : public IFunction
  413. {
  414. private:
  415. TRef<Modeler> m_pmodeler;
  416. public:
  417. ButtonPaneFactory(Modeler* pmodeler) :
  418. m_pmodeler(pmodeler)
  419. {
  420. }
  421. TRef<IObject> Apply(ObjectStack& stack)
  422. {
  423. TRef<Image> pimage; CastTo(pimage, (Value*)(IObject*)stack.Pop());
  424. TRef<Number> pnumberFaces; CastTo(pnumberFaces, (IObject*)stack.Pop());
  425. TRef<Boolean> pboolToggle; CastTo(pboolToggle, (IObject*)stack.Pop());
  426. DWORD dwFaces = (DWORD)pnumberFaces->GetValue();
  427. return
  428. CreateTrekButton(
  429. CreateButtonFacePane(
  430. pimage->GetSurface(),
  431. dwFaces
  432. ),
  433. pboolToggle->GetValue(),
  434. (dwFaces & ButtonFaceCheckedDown) ? mouseclickSound : positiveButtonClickSound
  435. );
  436. }
  437. };
  438. //////////////////////////////////////////////////////////////////////////////
  439. //
  440. // SoundButtonPane
  441. //
  442. //////////////////////////////////////////////////////////////////////////////
  443. /*
  444. namespace
  445. {
  446. class SoundEventSink : public IEventSink, public IIntegerEventSink
  447. {
  448. private:
  449. TRef<ISoundTemplate> m_ptemplate;
  450. public:
  451. SoundEventSink(ISoundTemplate* ptemplate)
  452. : m_ptemplate(ptemplate)
  453. {
  454. };
  455. bool OnEvent(IIntegerEventSource* pevent, int nCmd)
  456. {
  457. return OnEvent(pevent);
  458. }
  459. bool OnEvent(IEventSource* pevent)
  460. {
  461. GetWindow()->StartSound(m_ptemplate);
  462. // HACK: force the sound to start _now_
  463. // (some buttons cause events that take 1/5 of a second or so to
  464. // happen, and the delay in the sonic feedback for the mouse click
  465. // is annoying).
  466. GetWindow()->SoundEngineUpdate();
  467. return true;
  468. }
  469. };
  470. };
  471. */
  472. class SoundButtonPaneFactory : public IFunction
  473. {
  474. private:
  475. TRef<Modeler> m_pmodeler;
  476. public:
  477. SoundButtonPaneFactory(Modeler* pmodeler) :
  478. m_pmodeler(pmodeler)
  479. {
  480. }
  481. TRef<IObject> Apply(ObjectStack& stack)
  482. {
  483. TRef<Image> pimage; CastTo(pimage, (Value*)(IObject*)stack.Pop());
  484. TRef<Number> pnumberFaces; CastTo(pnumberFaces, (IObject*)stack.Pop());
  485. TRef<Boolean> pboolToggle; CastTo(pboolToggle, (IObject*)stack.Pop());
  486. TRef<Number> pnumberClickSoundId; CastTo(pnumberClickSoundId, (IObject*)stack.Pop());
  487. TRef<ButtonPane> pbutton =
  488. CreateButton(
  489. CreateButtonFacePane(
  490. pimage->GetSurface(),
  491. (DWORD)pnumberFaces->GetValue()
  492. ),
  493. pboolToggle->GetValue()
  494. );
  495. pbutton->GetMouseEnterWhileEnabledEventSource()->AddSink(new SoundIDEventSink(mouseoverSound));
  496. pbutton->GetEventSource()->AddSink(new SoundIDEventSink((SoundID)pnumberClickSoundId->GetValue()));
  497. return pbutton;
  498. }
  499. };
  500. //////////////////////////////////////////////////////////////////////////////
  501. //
  502. // ButtonBarPane
  503. //
  504. //////////////////////////////////////////////////////////////////////////////
  505. class ButtonBarPaneFactory : public IFunction {
  506. private:
  507. TRef<Modeler> m_pmodeler;
  508. public:
  509. ButtonBarPaneFactory(Modeler* pmodeler) :
  510. m_pmodeler(pmodeler)
  511. {
  512. }
  513. TRef<IObject> Apply(ObjectStack& stack)
  514. {
  515. TRef<Image> pimage; CastTo(pimage, (Value*)(IObject*)stack.Pop());
  516. TRef<Number> pnumberFaces; CastTo(pnumberFaces, (IObject*)stack.Pop());
  517. bool bActAsTabs = false;
  518. TVector<int> m_vecColumns;
  519. ParseIntVector((IObject*)stack.Pop(), m_vecColumns);
  520. if (stack.GetCount() > 0)
  521. {
  522. TRef<Boolean> pbooleanActAsTabs; CastTo(pbooleanActAsTabs, (IObject*)stack.Pop());
  523. bActAsTabs = pbooleanActAsTabs->GetValue();
  524. }
  525. TRef<ButtonBarPane> pbuttonbar =
  526. CreateButtonBarPane(
  527. pimage->GetSurface(),
  528. (DWORD)pnumberFaces->GetValue(),
  529. m_vecColumns,
  530. bActAsTabs
  531. );
  532. pbuttonbar->GetMouseEnterWhileEnabledEventSource()->AddSink(new SoundIDEventSink(mouseoverSound));
  533. pbuttonbar->GetEventSource()->AddSink(new SoundIDEventSink(mouseclickSound));
  534. return pbuttonbar;
  535. }
  536. };
  537. //////////////////////////////////////////////////////////////////////////////
  538. //
  539. // ImageComboPane
  540. //
  541. //////////////////////////////////////////////////////////////////////////////
  542. class ImageComboPaneFactory : public IFunction {
  543. private:
  544. TRef<Modeler> m_pmodeler;
  545. TRef<IPopupContainer> m_ppopupContainer;
  546. public:
  547. ImageComboPaneFactory(
  548. Modeler* pmodeler,
  549. IPopupContainer* ppopupContainer
  550. ) :
  551. m_pmodeler(pmodeler),
  552. m_ppopupContainer(ppopupContainer)
  553. {
  554. }
  555. TRef<IObject> Apply(ObjectStack& stack)
  556. {
  557. TRef<Image> pimage; CastTo(pimage, (Value*)(IObject*)stack.Pop());
  558. TRef<FontValue> pfont; CastTo(pfont, (IObject*)stack.Pop());
  559. TRef<ComboPane> pcombo =
  560. CreateComboPane(
  561. m_pmodeler,
  562. m_ppopupContainer,
  563. pfont->GetValue(),
  564. WinPoint(0, 0),
  565. CreateImageComboFacePane(pimage)
  566. );
  567. pcombo->GetMouseEnterWhileEnabledEventSource()->AddSink(new SoundIDEventSink(mouseoverSound));
  568. pcombo->GetMenuSelectEventSource()->AddSink(new SoundIDEventSink(mouseclickSound));
  569. return pcombo;
  570. }
  571. };
  572. //////////////////////////////////////////////////////////////////////////////
  573. //
  574. // StringComboPane
  575. //
  576. //////////////////////////////////////////////////////////////////////////////
  577. class StringComboPaneFactory : public IFunction {
  578. private:
  579. TRef<Modeler> m_pmodeler;
  580. TRef<IPopupContainer> m_ppopupContainer;
  581. public:
  582. StringComboPaneFactory(
  583. Modeler* pmodeler,
  584. IPopupContainer* ppopupContainer
  585. ) :
  586. m_pmodeler(pmodeler),
  587. m_ppopupContainer(ppopupContainer)
  588. {
  589. }
  590. TRef<IObject> Apply(ObjectStack& stack)
  591. {
  592. TRef<PointValue> ppointFace; CastTo(ppointFace, (IObject*)stack.Pop());
  593. TRef<PointValue> ppoint; CastTo(ppoint, (IObject*)stack.Pop());
  594. TRef<FontValue> pfont; CastTo(pfont, (IObject*)stack.Pop());
  595. TRef<ColorValue> pcolor; CastTo(pcolor, (IObject*)stack.Pop());
  596. TRef<ComboPane> pcombo =
  597. CreateComboPane(
  598. m_pmodeler,
  599. m_ppopupContainer,
  600. pfont->GetValue(),
  601. WinPoint::Cast(ppoint->GetValue()),
  602. CreateStringComboFacePane(
  603. WinPoint::Cast(ppointFace->GetValue()),
  604. pfont->GetValue(),
  605. pcolor->GetValue(),
  606. false
  607. )
  608. );
  609. pcombo->GetMouseEnterWhileEnabledEventSource()->AddSink(new SoundIDEventSink(mouseoverSound));
  610. pcombo->GetMenuSelectEventSource()->AddSink(new SoundIDEventSink(mouseclickSound));
  611. return pcombo;
  612. }
  613. };
  614. //////////////////////////////////////////////////////////////////////////////
  615. //
  616. // StringColorComboPane
  617. //
  618. //////////////////////////////////////////////////////////////////////////////
  619. class StringColorComboPaneFactory : public IFunction {
  620. private:
  621. TRef<Modeler> m_pmodeler;
  622. TRef<IPopupContainer> m_ppopupContainer;
  623. public:
  624. StringColorComboPaneFactory(
  625. Modeler* pmodeler,
  626. IPopupContainer* ppopupContainer
  627. ) :
  628. m_pmodeler(pmodeler),
  629. m_ppopupContainer(ppopupContainer)
  630. {
  631. }
  632. TRef<IObject> Apply(ObjectStack& stack)
  633. {
  634. TRef<PointValue> ppointFace; CastTo(ppointFace, (IObject*)stack.Pop());
  635. TRef<PointValue> ppoint; CastTo(ppoint, (IObject*)stack.Pop());
  636. TRef<FontValue> pfont; CastTo(pfont, (IObject*)stack.Pop());
  637. TRef<ColorValue> pcolor; CastTo(pcolor, (IObject*)stack.Pop());
  638. TRef<ComboPane> pcombo =
  639. CreateComboPane(
  640. m_pmodeler,
  641. m_ppopupContainer,
  642. pfont->GetValue(),
  643. WinPoint::Cast(ppoint->GetValue()),
  644. CreateStringComboFacePane(
  645. WinPoint::Cast(ppointFace->GetValue()),
  646. pfont->GetValue(),
  647. pcolor->GetValue(),
  648. true
  649. )
  650. );
  651. pcombo->GetMouseEnterWhileEnabledEventSource()->AddSink(new SoundIDEventSink(mouseoverSound));
  652. pcombo->GetMenuSelectEventSource()->AddSink(new SoundIDEventSink(mouseclickSound));
  653. return pcombo;
  654. }
  655. };
  656. //////////////////////////////////////////////////////////////////////////////
  657. //
  658. // Misc
  659. //
  660. //////////////////////////////////////////////////////////////////////////////
  661. void ExportPaneFactories(INameSpace* pns)
  662. {
  663. //
  664. // Display sides
  665. //
  666. pns->AddMember("SideLeft", new Number((float)ATLeft ));
  667. pns->AddMember("SideTopLeft", new Number((float)ATTopLeft ));
  668. pns->AddMember("SideTop", new Number((float)ATTop ));
  669. pns->AddMember("SideTopRight", new Number((float)ATTopRight ));
  670. pns->AddMember("SideRight", new Number((float)ATRight ));
  671. pns->AddMember("SideBottomRight", new Number((float)ATBottomRight));
  672. pns->AddMember("SideBottom", new Number((float)ATBottom ));
  673. pns->AddMember("SideBottomLeft", new Number((float)ATBottomLeft ));
  674. pns->AddMember("SideCenter", new Number((float)ATCenter ));
  675. // add our 'primitive' panes
  676. pns->AddMember("StringPane", new StringPaneFactory());
  677. pns->AddMember("GaugePane", new GaugePaneFactory());
  678. pns->AddMember("SwitchPane", new SwitchPaneFactory());
  679. pns->AddMember("ButtonPane", new ButtonPaneFactory(GetModeler()));
  680. pns->AddMember("SoundButtonPane", new SoundButtonPaneFactory(GetModeler()));
  681. pns->AddMember("ButtonBarPane",new ButtonBarPaneFactory(GetModeler()));
  682. pns->AddMember("ImageComboPane", new ImageComboPaneFactory(GetModeler(), GetWindow()->GetPopupContainer()));
  683. pns->AddMember("StringComboPane", new StringComboPaneFactory(GetModeler(), GetWindow()->GetPopupContainer()));
  684. pns->AddMember("StringColorComboPane", new StringColorComboPaneFactory(GetModeler(), GetWindow()->GetPopupContainer()));
  685. // add our 'specialty' panes
  686. #ifndef MARKCU1
  687. pns->AddMember("SectorMapPane", new SectorMapPaneFactory());
  688. pns->AddMember("SectorInfoPane", new SectorInfoPaneFactory());
  689. pns->AddMember("PartInfoPane", new PartInfoPaneFactory());
  690. pns->AddMember("PurchasesPane", new PurchasesPaneFactory());
  691. pns->AddMember("SelectionPane", new SelectionPaneFactory());
  692. pns->AddMember("SelectModelPane", new SelectModelPaneFactory());
  693. pns->AddMember("ChatListPane", new ChatListPaneFactory());
  694. pns->AddMember("InventoryImage", new InventoryImageFactory());
  695. #endif
  696. }