49 lines
1.5 KiB
Haxe
49 lines
1.5 KiB
Haxe
package ru.m.tankz.view.common;
|
|
|
|
import openfl.Assets;
|
|
import hw.view.ImageView;
|
|
import hw.view.form.LabelView;
|
|
import hw.view.form.SelectView;
|
|
import hw.view.group.HGroupView;
|
|
import hw.view.skin.SpriteSkin;
|
|
import ru.m.tankz.control.Controller;
|
|
import ru.m.tankz.control.PlayerControl;
|
|
|
|
@:template class SlotView extends HGroupView {
|
|
|
|
@:view("tank") public var tankView:ImageView;
|
|
@:view("slot") public var slotLabel:LabelView;
|
|
@:view("select") public var select:SelectView<Controller>;
|
|
|
|
public var control(default, set):PlayerControl;
|
|
public var tank(default, set):String;
|
|
|
|
private function set_control(value:PlayerControl):PlayerControl {
|
|
control = value;
|
|
slotLabel.text = '${control.playerId.team} #${control.playerId.index}';
|
|
var skin:SpriteSkin = cast slotLabel.skin;
|
|
skin.border.color = value.color;
|
|
skin.border.alpha = 0.8;
|
|
skin.background.color = value.color;
|
|
skin.background.alpha = 0.2;
|
|
select.selected = control.controller;
|
|
tankView.color = value.color;
|
|
return control;
|
|
}
|
|
|
|
private function set_tank(value:String):String {
|
|
if (tank != value) {
|
|
tank = value;
|
|
tankView.image = Assets.getBitmapData('resources/image/tank/${tank}-0.png');
|
|
}
|
|
return tank;
|
|
}
|
|
|
|
private function onControllerSelect(value:Controller):Void {
|
|
select.currentView.style = switch value {
|
|
case HUMAN(_): "button.active";
|
|
case _: "button";
|
|
}
|
|
}
|
|
}
|