Gui Skin.cpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801
  1. /******************************************************************************/
  2. #include "stdafx.h"
  3. namespace EE{
  4. /******************************************************************************/
  5. #define CC4_GSKN CC4('G','S','K','N')
  6. /******************************************************************************/
  7. GuiSkin EmptyGuiSkin;
  8. DEFINE_CACHE(GuiSkin, GuiSkins, GuiSkinPtr, "Gui Skin");
  9. /******************************************************************************/
  10. void GuiSkin::Button::reset()
  11. {
  12. disabled_color=normal_color.set(255); disabled_color.a/=2;
  13. pushed_disabled_color=pushed_color.set(192); pushed_disabled_color.a/=2;
  14. normal=pushed=disabled=pushed_disabled=null;
  15. text_size=0.85f; text_padd=0.15f; text_style=null;
  16. }
  17. Bool GuiSkin::Button::save(File &f, CChar *path)C
  18. {
  19. f.cmpUIntV(0); // version
  20. f<<normal_color<<pushed_color<<disabled_color<<pushed_disabled_color<<text_size<<text_padd;
  21. f._putAsset(normal .name(path));
  22. f._putAsset(pushed .name(path));
  23. f._putAsset(disabled .name(path));
  24. f._putAsset(pushed_disabled.name(path));
  25. f._putAsset(text_style .name(path));
  26. return f.ok();
  27. }
  28. Bool GuiSkin::Button::load(File &f, CChar *path)
  29. {
  30. switch(f.decUIntV()) // version
  31. {
  32. case 0:
  33. {
  34. f>>normal_color>>pushed_color>>disabled_color>>pushed_disabled_color>>text_size>>text_padd;
  35. normal .require(f._getAsset(), path);
  36. pushed .require(f._getAsset(), path);
  37. disabled .require(f._getAsset(), path);
  38. pushed_disabled.require(f._getAsset(), path);
  39. text_style .require(f._getAsset(), path);
  40. if(f.ok())return true;
  41. }break;
  42. }
  43. reset(); return false;
  44. }
  45. /******************************************************************************/
  46. void GuiSkin::ButtonImage::reset()
  47. {
  48. super::reset();
  49. image_color.set(255);
  50. image=null;
  51. }
  52. Bool GuiSkin::ButtonImage::save(File &f, CChar *path)C
  53. {
  54. f.cmpUIntV(0); // version
  55. super::save(f, path);
  56. f<<image_color;
  57. f._putAsset(image.name(path));
  58. return f.ok();
  59. }
  60. Bool GuiSkin::ButtonImage::load(File &f, CChar *path)
  61. {
  62. switch(f.decUIntV()) // version
  63. {
  64. case 0: if(super::load(f, path))
  65. {
  66. f>>image_color;
  67. image.require(f._getAsset(), path);
  68. if(f.ok())return true;
  69. }break;
  70. }
  71. reset(); return false;
  72. }
  73. /******************************************************************************/
  74. void GuiSkin::CheckBox::reset()
  75. {
  76. disabled_color=normal_color.set(255); disabled_color.a/=2;
  77. off=on=multi=null;
  78. }
  79. Bool GuiSkin::CheckBox::save(File &f, CChar *path)C
  80. {
  81. f.cmpUIntV(0); // version
  82. f<<normal_color<<disabled_color;
  83. f._putAsset(off .name(path));
  84. f._putAsset(on .name(path));
  85. f._putAsset(multi.name(path));
  86. return f.ok();
  87. }
  88. Bool GuiSkin::CheckBox::load(File &f, CChar *path)
  89. {
  90. switch(f.decUIntV()) // version
  91. {
  92. case 0:
  93. {
  94. f>>normal_color>>disabled_color;
  95. off .require(f._getAsset(), path);
  96. on .require(f._getAsset(), path);
  97. multi.require(f._getAsset(), path);
  98. if(f.ok())return true;
  99. }break;
  100. }
  101. reset(); return false;
  102. }
  103. /******************************************************************************/
  104. void GuiSkin::ComboBox::reset()
  105. {
  106. super::reset();
  107. }
  108. Bool GuiSkin::ComboBox::save(File &f, CChar *path)C
  109. {
  110. f.cmpUIntV(0); // version
  111. if(super::save(f, path))
  112. return f.ok();
  113. return false;
  114. }
  115. Bool GuiSkin::ComboBox::load(File &f, CChar *path)
  116. {
  117. switch(f.decUIntV()) // version
  118. {
  119. case 0: if(super::load(f, path))
  120. {
  121. if(f.ok())return true;
  122. }break;
  123. }
  124. reset(); return false;
  125. }
  126. /******************************************************************************/
  127. void GuiSkin::Desc::reset()
  128. {
  129. normal_color.set(255);
  130. padding=0.01f;
  131. normal=null;
  132. text_style=null;
  133. }
  134. Bool GuiSkin::Desc::save(File &f, CChar *path)C
  135. {
  136. f.cmpUIntV(0); // version
  137. f<<normal_color<<padding;
  138. f._putAsset(text_style.name(path));
  139. f._putAsset(normal .name(path));
  140. return f.ok();
  141. }
  142. Bool GuiSkin::Desc::load(File &f, CChar *path)
  143. {
  144. switch(f.decUIntV()) // version
  145. {
  146. case 0:
  147. {
  148. f>>normal_color>>padding;
  149. text_style.require(f._getAsset(), path);
  150. normal .require(f._getAsset(), path);
  151. if(f.ok())return true;
  152. }break;
  153. }
  154. reset(); return false;
  155. }
  156. /******************************************************************************/
  157. void GuiSkin::IMM::reset()
  158. {
  159. normal_color.set(255);
  160. padding=0.01f;
  161. normal=null;
  162. text_style=null;
  163. }
  164. Bool GuiSkin::IMM::save(File &f, CChar *path)C
  165. {
  166. f.cmpUIntV(0); // version
  167. f<<normal_color<<padding;
  168. f._putAsset(text_style.name(path));
  169. f._putAsset(normal .name(path));
  170. return f.ok();
  171. }
  172. Bool GuiSkin::IMM::load(File &f, CChar *path)
  173. {
  174. switch(f.decUIntV()) // version
  175. {
  176. case 0:
  177. {
  178. f>>normal_color>>padding;
  179. text_style.require(f._getAsset(), path);
  180. normal .require(f._getAsset(), path);
  181. if(f.ok())return true;
  182. }break;
  183. }
  184. reset(); return false;
  185. }
  186. /******************************************************************************/
  187. void GuiSkin::List::reset()
  188. {
  189. selection_color= cursor_color.set(0, 108, 255, 56);
  190. highlight_color=selection_color; highlight_color.a=29;
  191. cursor=highlight=selection=null;
  192. text_style=null;
  193. column.reset();
  194. resize_column=null;
  195. }
  196. Bool GuiSkin::List::save(File &f, CChar *path)C
  197. {
  198. f.cmpUIntV(1); // version
  199. f<<cursor_color<<highlight_color<<selection_color;
  200. f.putAsset(cursor .id());
  201. f.putAsset(highlight .id());
  202. f.putAsset(selection .id());
  203. f.putAsset(text_style .id());
  204. f.putAsset(resize_column.id());
  205. if(column.save(f, path))
  206. return f.ok();
  207. return false;
  208. }
  209. Bool GuiSkin::List::load(File &f, CChar *path)
  210. {
  211. switch(f.decUIntV()) // version
  212. {
  213. case 1:
  214. {
  215. f>>cursor_color>>highlight_color>>selection_color;
  216. cursor .require(f.getAssetID(), path);
  217. highlight .require(f.getAssetID(), path);
  218. selection .require(f.getAssetID(), path);
  219. text_style .require(f.getAssetID(), path);
  220. resize_column.require(f.getAssetID(), path);
  221. if(column.load(f, path))
  222. if(f.ok())return true;
  223. }break;
  224. case 0:
  225. {
  226. f>>cursor_color>>highlight_color>>selection_color;
  227. cursor .require(f._getAsset(), path);
  228. highlight .require(f._getAsset(), path);
  229. selection .require(f._getAsset(), path);
  230. text_style.require(f._getAsset(), path);
  231. resize_column=null;
  232. if(column.load(f, path))
  233. if(f.ok())return true;
  234. }break;
  235. }
  236. reset(); return false;
  237. }
  238. /******************************************************************************/
  239. void GuiSkin::Menu::reset()
  240. {
  241. normal_color=check_color=sub_menu_color.set(255);
  242. padding=0.01f;
  243. list_elm_height=0.043f;
  244. normal=null;
  245. check=sub_menu=null;
  246. }
  247. Bool GuiSkin::Menu::save(File &f, CChar *path)C
  248. {
  249. f.cmpUIntV(1); // version
  250. f<<normal_color<<check_color<<sub_menu_color<<padding<<list_elm_height;
  251. f.putAsset(normal .id());
  252. f.putAsset(check .id());
  253. f.putAsset(sub_menu.id());
  254. return f.ok();
  255. }
  256. Bool GuiSkin::Menu::load(File &f, CChar *path)
  257. {
  258. switch(f.decUIntV()) // version
  259. {
  260. case 1:
  261. {
  262. f>>normal_color>>check_color>>sub_menu_color>>padding>>list_elm_height;
  263. normal .require(f.getAssetID(), path);
  264. check .require(f.getAssetID(), path);
  265. sub_menu.require(f.getAssetID(), path);
  266. if(f.ok())return true;
  267. }break;
  268. case 0:
  269. {
  270. f>>normal_color>>check_color>>sub_menu_color>>padding; list_elm_height=0.043f;
  271. normal .require(f._getAsset(), path);
  272. check .require(f._getAsset(), path);
  273. sub_menu.require(f._getAsset(), path);
  274. if(f.ok())return true;
  275. }break;
  276. }
  277. reset(); return false;
  278. }
  279. /******************************************************************************/
  280. void GuiSkin::MenuBar::reset()
  281. {
  282. background_color.set(255);
  283. highlight_color.set(0, 108, 255, 64);
  284. bar_height=0.055f; text_size=0.9f; text_padd=0.8f;
  285. background=highlight=null;
  286. text_style=null;
  287. }
  288. Bool GuiSkin::MenuBar::save(File &f, CChar *path)C
  289. {
  290. f.cmpUIntV(0); // version
  291. f<<background_color<<highlight_color<<bar_height<<text_size<<text_padd;
  292. f._putAsset(background.name(path));
  293. f._putAsset(highlight .name(path));
  294. f._putAsset(text_style.name(path));
  295. return f.ok();
  296. }
  297. Bool GuiSkin::MenuBar::load(File &f, CChar *path)
  298. {
  299. switch(f.decUIntV()) // version
  300. {
  301. case 0:
  302. {
  303. f>>background_color>>highlight_color>>bar_height>>text_size>>text_padd;
  304. background.require(f._getAsset(), path);
  305. highlight .require(f._getAsset(), path);
  306. text_style.require(f._getAsset(), path);
  307. if(f.ok())return true;
  308. }break;
  309. }
  310. reset(); return false;
  311. }
  312. /******************************************************************************/
  313. void GuiSkin::Progress::reset()
  314. {
  315. draw_progress_partial=false;
  316. background_color=progress_color.set(255);
  317. text_size=0.8f;
  318. background=progress=null;
  319. text_style=null;
  320. }
  321. Bool GuiSkin::Progress::save(File &f, CChar *path)C
  322. {
  323. f.cmpUIntV(0); // version
  324. f<<draw_progress_partial<<background_color<<progress_color<<text_size;
  325. f._putAsset(background.name(path));
  326. f._putAsset(progress .name(path));
  327. f._putAsset(text_style.name(path));
  328. return f.ok();
  329. }
  330. Bool GuiSkin::Progress::load(File &f, CChar *path)
  331. {
  332. switch(f.decUIntV()) // version
  333. {
  334. case 0:
  335. {
  336. f>>draw_progress_partial>>background_color>>progress_color>>text_size;
  337. background.require(f._getAsset(), path);
  338. progress .require(f._getAsset(), path);
  339. text_style.require(f._getAsset(), path);
  340. if(f.ok())return true;
  341. }break;
  342. }
  343. reset(); return false;
  344. }
  345. /******************************************************************************/
  346. void GuiSkin::Property::reset()
  347. {
  348. value.reset();
  349. }
  350. Bool GuiSkin::Property::save(File &f, CChar *path)C
  351. {
  352. f.cmpUIntV(0); // version
  353. if(value.save(f, path))
  354. return f.ok();
  355. return false;
  356. }
  357. Bool GuiSkin::Property::load(File &f, CChar *path)
  358. {
  359. switch(f.decUIntV()) // version
  360. {
  361. case 0:
  362. {
  363. if(value.load(f, path))
  364. if(f.ok())return true;
  365. }break;
  366. }
  367. reset(); return false;
  368. }
  369. /******************************************************************************/
  370. void GuiSkin::Region::reset()
  371. {
  372. normal_color.set(255);
  373. normal=null;
  374. view.reset();
  375. }
  376. Bool GuiSkin::Region::save(File &f, CChar *path)C
  377. {
  378. f.cmpUIntV(0); // version
  379. f<<normal_color;
  380. f._putAsset(normal.name(path));
  381. if(view.save(f, path))
  382. return f.ok();
  383. return false;
  384. }
  385. Bool GuiSkin::Region::load(File &f, CChar *path)
  386. {
  387. switch(f.decUIntV()) // version
  388. {
  389. case 0:
  390. {
  391. f>>normal_color;
  392. normal.require(f._getAsset(), path);
  393. if(view.load(f, path))
  394. if(f.ok())return true;
  395. }break;
  396. }
  397. reset(); return false;
  398. }
  399. /******************************************************************************/
  400. void GuiSkin::SlideBar::reset()
  401. {
  402. background_color.set(255);
  403. background=null;
  404. left.reset(); center.reset(); right.reset();
  405. }
  406. Bool GuiSkin::SlideBar::save(File &f, CChar *path)C
  407. {
  408. f.cmpUIntV(0); // version
  409. f<<background_color;
  410. f._putAsset(background.name(path));
  411. if(left .save(f, path))
  412. if(center.save(f, path))
  413. if(right .save(f, path))
  414. return f.ok();
  415. return false;
  416. }
  417. Bool GuiSkin::SlideBar::load(File &f, CChar *path)
  418. {
  419. switch(f.decUIntV()) // version
  420. {
  421. case 0:
  422. {
  423. f>>background_color;
  424. background.require(f._getAsset(), path);
  425. if(left .load(f, path))
  426. if(center.load(f, path))
  427. if(right .load(f, path))
  428. if(f.ok())return true;
  429. }break;
  430. }
  431. reset(); return false;
  432. }
  433. /******************************************************************************/
  434. void GuiSkin::Slider::reset()
  435. {
  436. draw_progress_partial=false;
  437. background_color=progress_color=slider_color.set(255);
  438. background_shrink=0;
  439. background=progress=slider=null;
  440. }
  441. Bool GuiSkin::Slider::save(File &f, CChar *path)C
  442. {
  443. f.cmpUIntV(0); // version
  444. f<<draw_progress_partial<<background_color<<progress_color<<slider_color<<background_shrink;
  445. f._putAsset(background.name(path));
  446. f._putAsset(progress .name(path));
  447. f._putAsset(slider .name(path));
  448. return f.ok();
  449. }
  450. Bool GuiSkin::Slider::load(File &f, CChar *path)
  451. {
  452. switch(f.decUIntV()) // version
  453. {
  454. case 0:
  455. {
  456. f>>draw_progress_partial>>background_color>>progress_color>>slider_color>>background_shrink;
  457. background.require(f._getAsset(), path);
  458. progress .require(f._getAsset(), path);
  459. slider .require(f._getAsset(), path);
  460. if(f.ok())return true;
  461. }break;
  462. }
  463. reset(); return false;
  464. }
  465. /******************************************************************************/
  466. void GuiSkin::Tab::reset()
  467. {
  468. left.reset(); horizontal.reset(); right.reset(); top.reset(); vertical.reset(); bottom.reset();
  469. top_left.reset(); top_right.reset(); bottom_left.reset(); bottom_right.reset();
  470. }
  471. Bool GuiSkin::Tab::save(File &f, CChar *path)C
  472. {
  473. f.cmpUIntV(0); // version
  474. if(left .save(f, path))
  475. if(horizontal .save(f, path))
  476. if(right .save(f, path))
  477. if(top .save(f, path))
  478. if(vertical .save(f, path))
  479. if(bottom .save(f, path))
  480. if(top_left .save(f, path))
  481. if(top_right .save(f, path))
  482. if(bottom_left .save(f, path))
  483. if(bottom_right.save(f, path))
  484. return f.ok();
  485. return false;
  486. }
  487. Bool GuiSkin::Tab::load(File &f, CChar *path)
  488. {
  489. switch(f.decUIntV()) // version
  490. {
  491. case 0:
  492. {
  493. if(left .load(f, path))
  494. if(horizontal .load(f, path))
  495. if(right .load(f, path))
  496. if(top .load(f, path))
  497. if(vertical .load(f, path))
  498. if(bottom .load(f, path))
  499. if(top_left .load(f, path))
  500. if(top_right .load(f, path))
  501. if(bottom_left .load(f, path))
  502. if(bottom_right.load(f, path))
  503. if(f.ok())return true;
  504. }break;
  505. }
  506. reset(); return false;
  507. }
  508. /******************************************************************************/
  509. void GuiSkin::Text::reset()
  510. {
  511. text_style=null;
  512. }
  513. Bool GuiSkin::Text::save(File &f, CChar *path)C
  514. {
  515. f.cmpUIntV(0); // version
  516. f._putAsset(text_style.name(path));
  517. return f.ok();
  518. }
  519. Bool GuiSkin::Text::load(File &f, CChar *path)
  520. {
  521. switch(f.decUIntV()) // version
  522. {
  523. case 0:
  524. {
  525. text_style.require(f._getAsset(), path);
  526. if(f.ok())return true;
  527. }break;
  528. }
  529. reset(); return false;
  530. }
  531. /******************************************************************************/
  532. void GuiSkin::TextLine::reset()
  533. {
  534. normal_panel_color=normal_text_color=disabled_panel_color=disabled_text_color.set(255); disabled_panel_color.a/=2; disabled_text_color.a/=2;
  535. rect_color.set(0, 112);
  536. text_size=0.8f;
  537. normal=disabled=null;
  538. text_style=null;
  539. find_image=null;
  540. clear.reset();
  541. }
  542. Bool GuiSkin::TextLine::save(File &f, CChar *path)C
  543. {
  544. f.cmpUIntV(3); // version
  545. f<<normal_panel_color<<normal_text_color<<disabled_panel_color<<disabled_text_color<<rect_color<<text_size;
  546. f.putAsset(normal .id());
  547. f.putAsset(disabled .id());
  548. f.putAsset(text_style.id());
  549. f.putAsset(find_image.id());
  550. if(clear.save(f, path))
  551. return f.ok();
  552. return false;
  553. }
  554. Bool GuiSkin::TextLine::load(File &f, CChar *path)
  555. {
  556. switch(f.decUIntV()) // version
  557. {
  558. case 3:
  559. {
  560. f>>normal_panel_color>>normal_text_color>>disabled_panel_color>>disabled_text_color>>rect_color>>text_size;
  561. normal .require(f.getAssetID(), path);
  562. disabled .require(f.getAssetID(), path);
  563. text_style.require(f.getAssetID(), path);
  564. find_image.require(f.getAssetID(), path);
  565. if(clear.load(f, path))
  566. if(f.ok())return true;
  567. }break;
  568. case 2:
  569. {
  570. f>>normal_panel_color>>normal_text_color>>disabled_panel_color>>disabled_text_color>>rect_color; text_size=0.8f;
  571. normal .require(f.getAssetID(), path);
  572. disabled .require(f.getAssetID(), path);
  573. text_style.require(f.getAssetID(), path);
  574. find_image.require(f.getAssetID(), path);
  575. if(clear.load(f, path))
  576. if(f.ok())return true;
  577. }break;
  578. case 1:
  579. {
  580. f>>normal_panel_color>>normal_text_color>>disabled_panel_color>>disabled_text_color>>rect_color; text_size=0.8f;
  581. normal .require(f.getAssetID(), path);
  582. disabled .require(f.getAssetID(), path);
  583. text_style.require(f.getAssetID(), path);
  584. find_image.require(f.getAssetID(), path);
  585. clear.reset();
  586. if(f.ok())return true;
  587. }break;
  588. case 0:
  589. {
  590. f>>normal_panel_color>>disabled_panel_color>>rect_color; normal_text_color=normal_panel_color; disabled_text_color=disabled_panel_color; text_size=0.8f;
  591. normal .require(f._getAsset(), path);
  592. disabled .require(f._getAsset(), path);
  593. text_style.require(f._getAsset(), path);
  594. find_image.require(f._getAsset(), path);
  595. clear.reset();
  596. if(f.ok())return true;
  597. }break;
  598. }
  599. reset(); return false;
  600. }
  601. /******************************************************************************/
  602. void GuiSkin::Window::reset()
  603. {
  604. normal_color=active_color.set(255);
  605. text_size=0.87f; text_padd=0.15f;
  606. button_offset.zero();
  607. normal=active=normal_no_bar=active_no_bar=null;
  608. normal_text_style=active_text_style=null;
  609. minimize.reset();
  610. maximize.reset();
  611. close .reset();
  612. }
  613. Bool GuiSkin::Window::save(File &f, CChar *path)C
  614. {
  615. f.cmpUIntV(1); // version
  616. f<<normal_color<<active_color<<text_size<<text_padd<<button_offset;
  617. f.putAsset(normal .id());
  618. f.putAsset(active .id());
  619. f.putAsset(normal_no_bar .id());
  620. f.putAsset(active_no_bar .id());
  621. f.putAsset(normal_text_style.id());
  622. f.putAsset(active_text_style.id());
  623. if(minimize.save(f, path))
  624. if(maximize.save(f, path))
  625. if(close .save(f, path))
  626. return f.ok();
  627. return false;
  628. }
  629. Bool GuiSkin::Window::load(File &f, CChar *path)
  630. {
  631. switch(f.decUIntV()) // version
  632. {
  633. case 1:
  634. {
  635. f>>normal_color>>active_color>>text_size>>text_padd>>button_offset;
  636. normal .require(f.getAssetID(), path);
  637. active .require(f.getAssetID(), path);
  638. normal_no_bar .require(f.getAssetID(), path);
  639. active_no_bar .require(f.getAssetID(), path);
  640. normal_text_style.require(f.getAssetID(), path);
  641. active_text_style.require(f.getAssetID(), path);
  642. if(minimize.load(f, path))
  643. if(maximize.load(f, path))
  644. if(close .load(f, path))
  645. if(f.ok())return true;
  646. }break;
  647. case 0:
  648. {
  649. f>>normal_color>>active_color>>text_size>>text_padd; button_offset.zero();
  650. normal .require(f._getAsset(), path);
  651. active .require(f._getAsset(), path);
  652. normal_no_bar .require(f._getAsset(), path);
  653. active_no_bar .require(f._getAsset(), path);
  654. normal_text_style.require(f._getAsset(), path);
  655. active_text_style.require(f._getAsset(), path);
  656. if(minimize.load(f, path))
  657. if(maximize.load(f, path))
  658. if(close .load(f, path))
  659. if(f.ok())return true;
  660. }break;
  661. }
  662. reset(); return false;
  663. }
  664. /******************************************************************************/
  665. void GuiSkin::reset()
  666. {
  667. background_color.set(128);
  668. border_color.set(0, 112);
  669. mouse_highlight_color.set(20, 0);
  670. keyboard_highlight_color.set(86, 157, 229);
  671. font .clear();
  672. text_style.clear();
  673. button .reset();
  674. checkbox.reset();
  675. combobox.reset();
  676. desc .reset();
  677. imm .reset();
  678. list .reset();
  679. menu .reset();
  680. menubar .reset();
  681. progress.reset();
  682. property.reset();
  683. region .reset();
  684. slidebar.reset();
  685. slider .reset();
  686. tab .reset();
  687. text .reset();
  688. textline.reset();
  689. window .reset();
  690. }
  691. /******************************************************************************/
  692. Bool GuiSkin::save(File &f, CChar *path)C
  693. {
  694. f.putUInt (CC4_GSKN);
  695. f.cmpUIntV(1 ); // version
  696. f<<background_color<<border_color<<mouse_highlight_color<<keyboard_highlight_color;
  697. f.putAsset(font .id());
  698. f.putAsset(text_style.id());
  699. if(button .save(f, path))
  700. if(checkbox.save(f, path))
  701. if(combobox.save(f, path))
  702. if(desc .save(f, path))
  703. if(imm .save(f, path))
  704. if(list .save(f, path))
  705. if(menu .save(f, path))
  706. if(menubar .save(f, path))
  707. if(progress.save(f, path))
  708. if(property.save(f, path))
  709. if(region .save(f, path))
  710. if(slidebar.save(f, path))
  711. if(slider .save(f, path))
  712. if(tab .save(f, path))
  713. if(text .save(f, path))
  714. if(textline.save(f, path))
  715. if(window .save(f, path))
  716. return f.ok();
  717. return false;
  718. }
  719. Bool GuiSkin::load(File &f, CChar *path)
  720. {
  721. if(f.getUInt()==CC4_GSKN)switch(f.decUIntV()) // version
  722. {
  723. case 1:
  724. {
  725. f>>background_color>>border_color>>mouse_highlight_color>>keyboard_highlight_color;
  726. font .require(f.getAssetID(), path);
  727. text_style.require(f.getAssetID(), path);
  728. if(button .load(f, path))
  729. if(checkbox.load(f, path))
  730. if(combobox.load(f, path))
  731. if(desc .load(f, path))
  732. if(imm .load(f, path))
  733. if(list .load(f, path))
  734. if(menu .load(f, path))
  735. if(menubar .load(f, path))
  736. if(progress.load(f, path))
  737. if(property.load(f, path))
  738. if(region .load(f, path))
  739. if(slidebar.load(f, path))
  740. if(slider .load(f, path))
  741. if(tab .load(f, path))
  742. if(text .load(f, path))
  743. if(textline.load(f, path))
  744. if(window .load(f, path))
  745. if(f.ok())return true;
  746. }break;
  747. case 0:
  748. {
  749. f>>background_color>>border_color>>mouse_highlight_color>>keyboard_highlight_color;
  750. font .require(f._getAsset(), path);
  751. text_style.require(f._getAsset(), path);
  752. property.reset();
  753. if(button .load(f, path))
  754. if(checkbox.load(f, path))
  755. if(combobox.load(f, path))
  756. if(desc .load(f, path))
  757. if(imm .load(f, path))
  758. if(list .load(f, path))
  759. if(menu .load(f, path))
  760. if(menubar .load(f, path))
  761. if(progress.load(f, path))
  762. if(region .load(f, path))
  763. if(slidebar.load(f, path))
  764. if(slider .load(f, path))
  765. if(tab .load(f, path))
  766. if(text .load(f, path))
  767. if(textline.load(f, path))
  768. if(window .load(f, path))
  769. if(f.ok())return true;
  770. }break;
  771. }
  772. reset(); return false;
  773. }
  774. Bool GuiSkin::save(C Str &name)C
  775. {
  776. File f; if(f.writeTry(name)){if(save(f, _GetPath(name)) && f.flush())return true; f.del(); FDelFile(name);}
  777. return false;
  778. }
  779. Bool GuiSkin::load(C Str &name)
  780. {
  781. File f; if(f.readTry(name))return load(f, _GetPath(name));
  782. reset(); return false;
  783. }
  784. /*void GuiSkin::operator=(C Str &name)
  785. {
  786. if(!load(name))Exit(MLT(S+"Can't load Gui Skin \"" +name+"\"",
  787. PL,S+u"Nie można wczytać GuiSkin \""+name+"\""));
  788. }
  789. /******************************************************************************/
  790. }
  791. /******************************************************************************/