1// ==================
2// TRANSFER MENU
3// ==================
4component cmp_t_storage extends panel {
5	{
6		size		"475 20"
7		onClick {
8			cmd "ui_trans_add <node:this.id@string> 1;"
9		}
10		onRClick {
11			cmd "ui_trans_add <node:this.id@string> -1;"
12		}
13	}
14
15	data id {
16	}
17
18	string name {
19		pos			"0 0"
20		size		"250 20"
21		ghost		true
22		contentalign	ALIGN_CL
23	}
24	string src_store {
25		pos			"250 0"
26		size		"100 20"
27		contentalign	ALIGN_CR
28		ghost		true
29	}
30	spinner_blue spinner {
31		tooltip		"_Add/Remove item to transfer cargo, hold SHIFT for speed increase."
32		pos			"352 0"
33		size		"20 20"
34		shiftincreasefactor	10.0
35		onChange {
36			cmd "ui_trans_add <node:parent.id@string> <lastdiff>;"
37		}
38	}
39	string dst_store {
40		pos			"375 0"
41		size		"100 20"
42		contentalign	ALIGN_CR
43		ghost		true
44	}
45}
46
47component cmp_t_cargo extends panel {
48	{
49		size		"368 20"
50		onClick {
51			cmd "ui_trans_add <node:this.id@string> -1;"
52		}
53	}
54
55	data id {
56	}
57	string name {
58		pos			"0 0"
59		size		"268 20"
60		ghost		true
61		contentalign	ALIGN_CL
62	}
63	string amount {
64		pos			"268 0"
65		size		"100 20"
66		contentalign	ALIGN_CR
67		ghost		true
68	}
69}
70
71component cmp_t_capacity extends panel {
72	{
73		size		"340 20"
74	}
75	string name {
76		pos			"0 0"
77		size		"180 20"
78		contentalign	ALIGN_CL
79	}
80	string free {
81		pos			"180 0"
82		size		"70 20"
83		contentalign	ALIGN_CR
84	}
85	string separator {
86		string		"/"
87		pos			"250 0"
88		size		"20 20"
89		contentalign	ALIGN_CC
90	}
91	string max {
92		pos			"270 0"
93		size		"70 20"
94		contentalign	ALIGN_CR
95	}
96}
97
98window transfer
99{
100	/** @todo Remove me */
101	{ } // empty properties to fix parsing problem with "image" token (behaviour or property?)
102
103	// ==================
104	// background
105	// ==================
106
107	image background
108	{
109		src		"background/base_bg"
110	}
111
112	cmpBaseHeader baseHeader {
113	}
114
115	// ==================
116	// tab
117	// ==================
118
119	panel tab_background {
120		pos		"24 96"
121		size	"986 56"
122		background	"ui/panel_tab"
123	}
124
125	tab trans_navigation {
126		{
127			pos		"47 106"
128			size	"938 39"
129			cvar	*cvar:mn_itemtype
130			onChange	{
131				cmd "ui_trans_fill <cvar:mn_itemtype>;"
132				if ( *cvar:mn_itemtype eq "item" ) {
133					*cvar:mn_itemtype_name = "_Equipment"
134				} elif ( *cvar:mn_itemtype eq "employee" ) {
135					*cvar:mn_itemtype_name = "_Employees"
136				} elif ( *cvar:mn_itemtype eq "alien" ) {
137					*cvar:mn_itemtype_name = "_Aliens"
138				} elif ( *cvar:mn_itemtype eq "aircraft" ) {
139					*cvar:mn_itemtype_name = "_Aircraft"
140				}
141			}
142		}
143		option item {
144			label	"_Equipment"
145			value	"item"
146			icon	"icons/tab_equipment"
147		}
148		option employee {
149			label	"_Employees"
150			value	"employee"
151			icon	"icons/tab_employees"
152		}
153		option alien {
154			label	"_Aliens"
155			value	"alien"
156			icon	"icons/tab_aliens"
157		}
158		option aircraft {
159			label	"_Aircraft"
160			value	"aircraft"
161			icon	"icons/tab_aircraft"
162		}
163	}
164
165	// ==================
166	// lists
167	// ==================
168
169	panel itemlist {
170		{
171			pos			"12 160"
172			size		"552 582"
173			background	"ui/panel_grey_green_large2"
174		}
175
176		rows lines {
177			pos			"16 16"
178			size		"520 550"
179			color1		"0 0.08 0 1"
180			color2		"0 0.16 0 1"
181			lineheight	20
182		}
183
184		string title_name {
185			string		*cvar:mn_itemtype_name
186			pos			"25 16"
187			size		"250 20"
188			contentalign	ALIGN_CL
189			font		"f_small_bold"
190		}
191
192		string title_src_store {
193			string		"_From"
194			pos			"275 16"
195			size		"100 20"
196			contentalign	ALIGN_CR
197			font		"f_small_bold"
198		}
199		string dst_store {
200			string		"_To"
201			pos			"400 16"
202			size		"100 20"
203			contentalign	ALIGN_CR
204			font		"f_small_bold"
205		}
206
207		panel translist {
208			pos			"25 36"
209			size		"475 520"
210			layout		LAYOUT_TOP_DOWN_FLOW
211
212			onViewChange {
213				*node:parent.translist_scroll@fullsize = <fullsize>
214				*node:parent.translist_scroll@current = <viewpos>
215				*node:parent.translist_scroll@viewsize = <viewsize>
216			}
217		}
218		vscrollbar translist_scroll {
219			image		"ui/scrollbar_v_green"
220			pos			"510 36"
221			height		"520"
222			hidewhenunused	true
223			onChange	{
224				*node:parent.translist@viewpos = <current>
225			}
226		}
227
228		confunc ui_translist_clear {
229			call *node:parent.translist@removeAllchild
230		}
231
232		confunc ui_translist_add {
233			call *node:parent.translist@createChild("trans_<1>", "cmp_t_storage")
234
235			*node:parent.translist.trans_<1>.id@string = <1>
236			*node:parent.translist.trans_<1>.name@string = <2>
237			*node:parent.translist.trans_<1>.src_store@string = <3>
238			if ( *node:parent.translist.trans_<1>.src_store@string eq "-1" ) {
239				*node:parent.translist.trans_<1>.src_store@invis = true
240			} else {
241				*node:parent.translist.trans_<1>.src_store@invis = false
242			}
243			*node:parent.translist.trans_<1>.dst_store@string = <4>
244			if ( *node:parent.translist.trans_<1>.dst_store@string eq "-1" ) {
245				*node:parent.translist.trans_<1>.dst_store@invis = true
246			} else {
247				*node:parent.translist.trans_<1>.dst_store@invis = false
248			}
249			*node:parent.translist.trans_<1>.spinner@min = <5>
250			*node:parent.translist.trans_<1>.spinner@current = <6>
251			*node:parent.translist.trans_<1>.spinner@max = <7>
252			if ( *node:parent.translist.trans_<1>.spinner@max == -1 ) {
253				*node:parent.translist.trans_<1>.spinner@invis = true
254			} else {
255				*node:parent.translist.trans_<1>.spinner@invis = false
256			}
257		}
258	}
259
260	/**
261	 * @brief Cargolist
262	 */
263	panel transfer_cargolist {
264		{
265			pos		"580 440"
266			size	"420 257"
267			background	"ui/panel_grey_green_large2"
268		}
269
270		rows lines_transfer_cargolist {
271			pos			"16 16"
272			size		"388 225"
273			color1		"0 0.08 0 1"
274			color2		"0 0.16 0 1"
275			lineheight	20
276		}
277
278		string title_name {
279			string		"_Cargo"
280			pos			"16 16"
281			size		"268 20"
282			contentalign	ALIGN_CL
283			font		"f_small_bold"
284		}
285
286		string title_amount {
287			string		"_Amount"
288			pos			"284 16"
289			size		"100 20"
290			contentalign	ALIGN_CR
291			font		"f_small_bold"
292		}
293
294		panel cargolist {
295			pos			"16 36"
296			size		"368 220"
297			layout		LAYOUT_TOP_DOWN_FLOW
298
299			onViewChange {
300				*node:parent.cargolist_scroll@fullsize = <fullsize>
301				*node:parent.cargolist_scroll@current = <viewpos>
302				*node:parent.cargolist_scroll@viewsize = <viewsize>
303			}
304		}
305		vscrollbar cargolist_scroll {
306			image		"ui/scrollbar_v_green"
307			pos			"384 36"
308			height		"220"
309			hidewhenunused	true
310			onChange	{
311				*node:parent.cargolist@viewpos = <current>
312			}
313		}
314
315		confunc ui_cargolist_clear {
316			call *node:parent.cargolist@removeAllchild
317		}
318
319		confunc ui_cargolist_add {
320			call *node:parent.cargolist@createChild("cargo_<1>", "cmp_t_cargo")
321
322			*node:parent.cargolist.cargo_<1>.id@string = <1>
323			*node:parent.cargolist.cargo_<1>.name@string = <2>
324			*node:parent.cargolist.cargo_<1>.amount@string = <3>
325		}
326	}
327
328	// ==================
329	// change target base
330	// ==================
331	panel infopanel {
332		{
333			pos		"580 160"
334			size	"420 260"
335			background	"ui/panel_grey_green_large"
336		}
337
338		string s_current_base {
339			string		"_Destination base"
340			pos			"20 22"
341			size		"380 20"
342			contentalign	ALIGN_UC
343			color		"0.7 0.7 0.7 1"
344			font		"f_small"
345		}
346
347		selectbox destination_base 	{
348			cvar		*cvar:mn_trans_base_id
349			pos			"64 45"
350			size		"288 20"
351			dataid		OPTION_BASELIST
352			onChange {
353				cmd "trans_selectbase <cvar:mn_trans_base_id>;"
354				cmd "ui_trans_fill <cvar:mn_itemtype>;"
355			}
356		}
357
358		string s_cap_building {
359			string		"_Building"
360			pos			"40 90"
361			size		"180 20"
362			contentalign	ALIGN_UL
363			color		"0.7 0.7 0.7 1"
364			font		"f_small"
365		}
366		string s_cap_freespace {
367			string		"_free"
368			pos			"220 90"
369			size		"70 20"
370			contentalign	ALIGN_UR
371			color		"0.7 0.7 0.7 1"
372			font		"f_small"
373		}
374		string s_cap_per {
375			string		"/"
376			pos			"290 90"
377			size		"20 20"
378			contentalign	ALIGN_UC
379			color		"0.7 0.7 0.7 1"
380			font		"f_small"
381		}
382		string s_cap_allspace {
383			string		"_all space"
384			pos			"310 90"
385			size		"70 20"
386			contentalign	ALIGN_UR
387			color		"0.7 0.7 0.7 1"
388			font		"f_small"
389		}
390		panel capacities {
391			pos			"40 115"
392			size		"340 125"
393			layout		LAYOUT_TOP_DOWN_FLOW
394			onViewChange {
395				*node:parent.t_baseinfo_scroll@fullsize = <fullsize>
396				*node:parent.t_baseinfo_scroll@current = <viewpos>
397				*node:parent.t_baseinfo_scroll@viewsize = <viewsize>
398			}
399		}
400
401		vscrollbar t_baseinfo_scroll {
402			image		"ui/scrollbar_v_green"
403			pos			"383 115"
404			height		"125"
405			hidewhenunused	true
406			onChange	{
407				*node:parent.capacities@viewpos = <current>
408			}
409		}
410
411		confunc ui_t_capacities_clear {
412			call *node:parent.capacities@removeAllchild
413			cmd "trans_disable enable;"
414		}
415		confunc ui_t_capacities_add {
416			call *node:parent.capacities@createChild("cap_<1>", "cmp_t_capacity")
417
418			*node:parent.capacities.cap_<1>.name@string = <2>
419			*node:parent.capacities.cap_<1>.free@string = ( <4> - <3> )
420			*node:parent.capacities.cap_<1>.max@string = <4>
421
422			if ( <3> > <4>) {
423				*node:parent.capacities.cap_<1>.name@color = "1 0 0 1"
424				*node:parent.capacities.cap_<1>.free@color = "1 0 0 1"
425				*node:parent.capacities.cap_<1>.max@color = "1 0 0 1"
426				cmd "trans_disable disable \"_Capacity overload\";"
427			} else {
428				*node:parent.capacities.cap_<1>.name@color = "1 1 1 1"
429				*node:parent.capacities.cap_<1>.free@color = "1 1 1 1"
430				*node:parent.capacities.cap_<1>.max@color = "1 1 1 1"
431			}
432		}
433
434	}
435
436	data transfer_denied {
437		integer 		0
438	}
439
440	confunc trans_disable {
441		if ( <1> eq "enable" ) {
442			*node:root.transfer_denied@integer = 0
443			*node:root.bt_starttrans@color = "1 1 1 0.6"
444			*node:root.bt_starttrans@selectcolor = "1 1 1 0.6"
445			*node:root.bt_starttrans@tooltip = "_Start the transfer"
446		} elif ( <1> eq "disable" ) {
447			*node:root.transfer_denied@integer = 1
448			*node:root.bt_starttrans@color = "1 0 0 0.6"
449			*node:root.bt_starttrans@selectcolor = "1 0 0 0.6"
450			*node:root.bt_starttrans@tooltip = "<2>"
451		}
452	}
453
454	// ==================
455	// buttons
456	// ==================
457	button bt_translist
458	{
459		string		"_List"
460		tooltip		"_List active transfers"
461		background		"ui/button_blue"
462		pos			"580 711"
463		size		"128 52"
464		color		"1 1 1 0.6"
465		selectcolor	"1 1 1 0.6"
466		font		"f_normal"
467		onClick		{ cmd "ui_push popup_transferlist;" }
468	}
469
470	button bt_starttrans
471	{
472		string		"_Transfer"
473		tooltip		"_Start the transfer"
474		background		"ui/button_blue"
475		pos			"725 711"
476		size		"128 52"
477		color		"1 1 1 0.6"
478		selectcolor	"1 1 1 0.6"
479		font		"f_normal"
480		onClick	{
481			if ( *node:root.transfer_denied@integer == 0 ) {
482				cmd "trans_start;"
483			}
484		}
485	}
486
487	button bt_emptycraftstorage
488	{
489		string		"_Clear"
490		tooltip		"_Clear cargo"
491		background		"ui/button_blue"
492		pos			"870 711"
493		size		"128 52"
494		color		"1 1 1 0.6"
495		selectcolor	"1 1 1 1"
496		font		"f_normal"
497		onClick		{ cmd "trans_emptyairstorage;" }
498	}
499
500	// ==================
501	// init function
502	// ==================
503
504	func onWindowOpened
505	{
506		cmd "trans_init;"
507		if ( *cvar:mn_itemtype_name eq "" ) { *cvar:mn_itemtype_name = "_Equipment" }
508		*cvar:mn_lastsubmenu = "transfer"
509	}
510
511	func onWindowClosed
512	{
513		cmd "trans_close;"
514
515		// Call base_init so storage data can be updated
516		cmd "base_init;"
517	}
518}
519
520// ===============================
521// POPUP TRANSFER BASE SELECT LIST
522// ===============================
523window popup_transferbaselist
524{
525	{
526		pos			"264 262"
527		size		"496 247"
528		dragbutton	true
529		background		"ui/popup_alpha_tile"
530		string		"_Select base to transfer to"
531	}
532
533	string info
534	{
535		string		"_Choose a base to host alien bodies:"
536		pos			"26 54"
537		size		"450 20"
538	}
539
540	optionlist trans_baselist
541	{
542		cvar		*cvar:tr_base
543		dataid		OPTION_BASELIST
544		pos			"26 74"
545		size		"450 112"
546		onChange	{ cmd "trans_baselist_click <cvar:tr_base>;" }
547		onRClick	{ cmd "ui_pop; aircraft_return;" }
548	}
549
550	cmpCancelButton bt_cancel
551	{
552		pos			"266 188"
553		onClick		{ cmd "ui_pop; aircraft_return;" }
554	}
555
556	func onWindowOpened {
557		*cvar:tr_base = -1
558	}
559}
560
561// ===================
562// POPUP TRANSFER LIST
563// ===================
564
565component trListEntry extends panel
566{
567	{
568		size		"472 150"
569		ghost		true
570		border		1
571		bordercolor	"0 .78 0 1"
572		ghost		true
573	}
574
575	string tr_from {
576		string		"_From:"
577		pos			"0 0"
578		size		"75 20"
579		font		"f_small_bold"
580		ghost		true
581	}
582	string tr_srcbase {
583		pos			"80 0"
584		size		"150 25"
585		font		"f_small"
586		ghost		true
587	}
588
589	string tr_to {
590		string		"_To:"
591		pos			"235 0"
592		size		"75 20"
593		font		"f_small_bold"
594		ghost		true
595	}
596	string tr_destbase {
597		pos			"315 0"
598		size		"150 25"
599		font		"f_small"
600		ghost		true
601	}
602
603	string tr_eta {
604		string		"_ETA:"
605		pos			"235 25"
606		size		"75 20"
607		font		"f_small_bold"
608		ghost		true
609	}
610	string tr_arrive {
611		pos			"315 25"
612		size		"150 25"
613		font		"f_small"
614		ghost		true
615	}
616
617	optiontree tr_cargo {
618		{
619			cvar		*cvar:none
620			pos			"0 50"
621			size		"472 100"
622			color		"0 .78 0 1"
623			selectcolor	"0 .78 0 1"
624			lineHeight	18
625
626			// event mimic missing dynamic nodesize feature
627			onViewchange	{
628				*node:this@height = ((<fullsize> * <lineHeight>) + (<padding> * 2))
629				*node:parent@height = (((<fullsize> * <lineHeight>) + (<padding> * 2)) + <top>)
630			}
631
632			// events mimic "ghost-wheel" functionality
633			onWheelUp {
634				*cvar:wheelpos = (*node:root.tr_list@viewpos - 1)
635				if (*cvar:wheelpos < 0) {
636					*cvar:wheelpos = 0
637				}
638
639				*node:root.tr_list@viewpos = <cvar:wheelpos>
640				*node:root.tr_list_scroll@current = <cvar:wheelpos>
641				delete *cvar:wheelpos
642			}
643			onWheelDown {
644				*cvar:wheelpos = (*node:root.tr_list@viewpos + 1)
645				if (*cvar:wheelpos > (*node:root.tr_list@fullsize - *node:root.tr_list@viewsize)) {
646					*cvar:wheelpos = (*node:root.tr_list@fullsize - *node:root.tr_list@viewsize)
647				}
648
649				*node:root.tr_list@viewpos = <cvar:wheelpos>
650				*node:root.tr_list_scroll@current = <cvar:wheelpos>
651				delete *cvar:wheelpos
652			}
653		}
654	}
655}
656
657window popup_transferlist
658{
659	{
660		pos			"226 226"
661		size		"542 512"
662		dragbutton	true
663		background		"ui/popup_alpha_tile"
664		string		"_Actual transfers"
665		modal		true
666	}
667
668	panel tr_list {
669		pos			"20 60"
670		size		"477 380"
671		layout		LAYOUT_TOP_DOWN_FLOW
672		wheelscrollable	true
673
674		onViewChange	{
675			*node:parent.tr_list_scroll@fullsize = <fullsize>
676			*node:parent.tr_list_scroll@current = <viewpos>
677			*node:parent.tr_list_scroll@viewsize = <viewsize>
678		}
679	}
680	vscrollbar tr_list_scroll {
681		image		"ui/scrollbar_v_green"
682		pos			"500 60"
683		height		"380"
684		hidewhenunused	true
685		onChange	{
686			*node:parent.tr_list@viewpos = <current>
687		}
688	}
689
690	cmpPopupButton tr_close
691	{
692		string		"_Close"
693		pos			"183 450"
694		onClick		{ cmd "ui_pop;" }
695	}
696
697	confunc tr_listclear {
698		call *node:root.tr_list@removeAllChild
699	}
700
701	confunc tr_listaddtransfer {
702		call *node:root.tr_list@createChild("trans<1>", "trListEntry")
703		*node:root.tr_list.trans<1>.tr_srcbase@string = <2>
704		*node:root.tr_list.trans<1>.tr_destbase@string = <3>
705		*node:root.tr_list.trans<1>.tr_arrive@string = <4>
706	}
707
708	confunc tr_listaddcargo {
709		call *node:root.tr_list.trans<1>.<2>@createChild("<3>", "option")
710		*node:root.tr_list.trans<1>.<2>.<3>@label = "<4>"
711		*node:root.tr_list.trans<1>.<2>.<3>@collapsed = true
712	}
713
714	func onWindowOpened
715	{
716		cmd "trans_list;"
717	}
718
719	func onWindowClosed {
720		call *node:root.tr_listclear
721	}
722}
723