Changeset 300


Ignore:
Timestamp:
Jul 10, 2019, 10:46:20 PM (5 years ago)
Author:
chronos
Message:
  • Added: Hide player options applicatble only for computer player.
  • Modified: Better selection of player and nation colors.
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormItem.lfm

    r299 r300  
    11object FormItem: TFormItem
    22  Left = 570
    3   Height = 300
     3  Height = 360
    44  Top = 429
    5   Width = 400
     5  Width = 480
    66  Caption = 'Item'
    7   ClientHeight = 300
    8   ClientWidth = 400
    9   DesignTimePPI = 120
     7  ClientHeight = 360
     8  ClientWidth = 480
     9  DesignTimePPI = 144
    1010  OnClose = FormClose
    1111  OnCreate = FormCreate
     
    1414  LCLVersion = '2.0.2.0'
    1515  object ButtonOk: TButton
    16     Left = 74
    17     Height = 32
    18     Top = 260
    19     Width = 94
     16    Left = 89
     17    Height = 38
     18    Top = 312
     19    Width = 113
    2020    Anchors = [akLeft, akBottom]
    2121    Caption = 'OK'
     
    2626  end
    2727  object ButtonCancel: TButton
    28     Left = 220
    29     Height = 32
    30     Top = 260
    31     Width = 94
     28    Left = 264
     29    Height = 38
     30    Top = 312
     31    Width = 113
    3232    Anchors = [akLeft, akBottom]
    3333    Caption = 'Cancel'
  • trunk/Forms/UFormItem.pas

    r298 r300  
    2424    FItem: TItem;
    2525    DataControls: TFPGObjectList<TControl>;
     26    DataLabels: TFPGObjectList<TLabel>;
     27    procedure ControlChangeExecute(Sender: TObject);
    2628    procedure SetItem(AValue: TItem);
    2729    procedure LoadData(Item: TItem); virtual;
     
    2931    procedure InitControls;
    3032  public
     33    procedure UpdateInterface;
    3134    property Item: TItem read FItem write SetItem;
    3235  end;
     
    6063  Core.ThemeManager1.UseTheme(Self);
    6164  DataControls := TFPGObjectList<TControl>.Create;
     65  DataLabels := TFPGObjectList<TLabel>.Create;
    6266end;
    6367
    6468procedure TFormItem.FormDestroy(Sender: TObject);
    6569begin
     70  DataLabels.Free;
    6671  DataControls.Free;
    6772end;
     
    7075begin
    7176  Core.PersistentForm.Load(Self);
     77end;
     78
     79procedure TFormItem.ControlChangeExecute(Sender: TObject);
     80begin
     81  UpdateInterface;
    7282end;
    7383
     
    130140  end;
    131141  Fields.Free;
     142  UpdateInterface;
    132143end;
    133144
     
    165176  Y: Integer;
    166177begin
    167   Y := 8;
     178  DataControls.Clear;
     179  DataLabels.Clear;
     180  Y := Scale96ToScreen(8);
    168181  Fields := Item.GetFields;
    169182  for I := 0 to Fields.Count - 1 do
    170183  with TItemField(Fields[I]) do begin
    171184    NewLabel := TLabel.Create(Self);
    172     NewLabel.Left := 8;
     185    NewLabel.Left := Scale96ToScreen(8);
    173186    NewLabel.Top := Y;
    174187    NewLabel.Parent := Self;
    175188    NewLabel.Caption := Name + ':';
    176189    NewLabel.Visible := True;
     190    DataLabels.Add(NewLabel);
    177191
    178192    if DataType = dtInteger then begin
    179193      NewControl := TSpinEdit.Create(nil);
    180       NewControl.Width := 100;
     194      NewControl.Width := Scale96ToScreen(100);
    181195      TSpinEdit(NewControl).MaxValue := High(Integer);
    182196    end else
    183197    if DataType = dtString then begin
    184198      NewControl := TEdit.Create(nil);
    185       NewControl.Width := 300;
     199      NewControl.Width := Scale96ToScreen(300);
    186200    end else
    187201    if DataType = dtColor then begin
    188202      NewControl := TColorBox.Create(nil);
    189       NewControl.Width := 200;
     203      NewControl.Width := Scale96ToScreen(200);
     204      TColorBox(NewControl).Style := [cbStandardColors, cbExtendedColors,
     205        cbCustomColor, cbPrettyNames];
    190206    end else
    191207    if DataType = dtEnumeration then begin
    192208      NewControl := TComboBox.Create(nil);
    193       NewControl.Width := 200;
     209      NewControl.Width := Scale96ToScreen(200);
    194210      TComboBox(NewControl).Style := csDropDownList;
     211      TComboBox(NewControl).OnChange := ControlChangeExecute;
    195212    end else
    196213    if DataType = dtReference then begin
    197214      NewControl := TComboBox.Create(nil);
    198       NewControl.Width := 200;
     215      NewControl.Width := Scale96ToScreen(200);
    199216      TComboBox(NewControl).Style := csDropDownList;
    200217    end else
     
    203220    end else
    204221      raise Exception.Create(Format(SUnsupportedDataType, [DataTypeStr[DataType]]));
    205     NewControl.Left := 150;
     222    NewControl.Left := Scale96ToScreen(150);
    206223    NewControl.Top := Y;
    207224    NewControl.Parent := Self;
     
    210227    NewControl.Visible := True;
    211228    DataControls.Add(NewControl);
    212     Y := Y + 40;
     229    Y := Y + Scale96ToScreen(30);
    213230  end;
    214231  Fields.Free;
    215232end;
    216233
     234procedure TFormItem.UpdateInterface;
     235var
     236  I: Integer;
     237  Fields: TItemFields;
     238  Condition: Boolean;
     239begin
     240  Fields := Item.GetFields;
     241  try
     242    for I := 0 to Fields.Count - 1 do
     243    with TItemField(Fields[I]) do begin
     244      if VisibleIfIndex > 0 then begin
     245        if TItemField(Fields[VisibleIfIndex]).DataType = dtEnumeration then begin
     246          Condition := TComboBox(DataControls[VisibleIfIndex]).ItemIndex > 0;
     247        end else Condition := False;
     248      end;
     249      DataControls[I].Visible := (VisibleIfIndex = 0) or ((VisibleIfIndex > 0) and Condition);
     250      DataLabels[I].Visible := DataControls[I].Visible;
     251    end;
     252  finally
     253    Fields.Free;
     254  end;
     255end;
     256
    217257end.
    218258
  • trunk/Forms/UFormList.lfm

    r298 r300  
    11object FormList: TFormList
    22  Left = 779
    3   Height = 300
     3  Height = 360
    44  Top = 236
    5   Width = 400
     5  Width = 480
    66  Caption = 'List'
    7   ClientHeight = 300
    8   ClientWidth = 400
    9   DesignTimePPI = 120
     7  ClientHeight = 360
     8  ClientWidth = 480
     9  DesignTimePPI = 144
    1010  OnClose = FormClose
    1111  OnCreate = FormCreate
     
    1414  object ListView1: TListView
    1515    Left = 0
    16     Height = 268
     16    Height = 322
    1717    Top = 0
    18     Width = 400
     18    Width = 480
    1919    Align = alClient
    2020    Columns = <   
    2121      item
    2222        Caption = 'Name'
    23         Width = 388
     23        Width = 466
    2424      end>
    2525    MultiSelect = True
     
    3939  object ToolBar1: TToolBar
    4040    Left = 0
    41     Top = 268
    42     Width = 400
     41    Height = 38
     42    Top = 322
     43    Width = 480
    4344    Align = alBottom
    44     Images = Core.ImageListSmall
    4545    ParentFont = False
    4646    TabOrder = 1
     
    5151    end
    5252    object ToolButton2: TToolButton
    53       Left = 30
     53      Left = 36
    5454      Top = 2
    5555      Action = AModify
    5656    end
    5757    object ToolButton3: TToolButton
    58       Left = 59
     58      Left = 71
    5959      Top = 2
    6060      Action = ARemove
    6161    end
    6262    object ToolButton4: TToolButton
    63       Left = 88
     63      Left = 106
    6464      Top = 2
    6565      Action = AClone
     
    6767  end
    6868  object ActionList1: TActionList
    69     Images = Core.ImageListSmall
    70     left = 173
    71     top = 136
     69    left = 208
     70    top = 163
    7271    object AAdd: TAction
    7372      Caption = 'Add'
     
    9796  end
    9897  object PopupMenu1: TPopupMenu
    99     Images = Core.ImageListSmall
    100     left = 293
    101     top = 133
     98    left = 352
     99    top = 160
    102100    object MenuItem1: TMenuItem
    103101      Action = AAdd
  • trunk/Forms/UFormList.pas

    r298 r300  
    276276    for I := 0 to ListView1.Columns.Count - 1 do begin
    277277      ListView1.Columns[I].Caption := Fields[I].Name;
    278       ListView1.Columns[I].Width := 100;
     278      ListView1.Columns[I].Width := Scale96ToScreen(100);
    279279    end;
    280280  finally
  • trunk/Languages/xtactics.cs.po

    r298 r300  
    99"MIME-Version: 1.0\n"
    1010"Content-Transfer-Encoding: 8bit\n"
    11 "X-Generator: Poedit 2.2\n"
     11"X-Generator: Poedit 2.2.1\n"
    1212"Language: cs\n"
    1313
     
    12221222msgstr "Zůstat naživu určený počet tahů"
    12231223
     1224#: uformplayer.sagrohigh
     1225msgctxt "uformplayer.sagrohigh"
     1226msgid "High"
     1227msgstr "Vysoká"
     1228
     1229#: uformplayer.sagrolow
     1230msgctxt "uformplayer.sagrolow"
     1231msgid "Low"
     1232msgstr "Nízká"
     1233
     1234#: uformplayer.sagromedium
     1235msgctxt "uformplayer.sagromedium"
     1236msgid "Medium"
     1237msgstr "Střední"
     1238
     1239#: uformplayer.scomputer
     1240msgctxt "uformplayer.scomputer"
     1241msgid "Computer"
     1242msgstr "Počítač"
     1243
     1244#: uformplayer.shuman
     1245msgctxt "uformplayer.shuman"
     1246msgid "Human"
     1247msgstr "Člověk"
     1248
     1249#: uformplayers.sremoveitems
     1250msgctxt "uformplayers.sremoveitems"
     1251msgid "Remove items"
     1252msgstr "Odstranit položky"
     1253
     1254#: uformplayers.sremoveitemsquery
     1255msgctxt "uformplayers.sremoveitemsquery"
     1256msgid "Do you want to remove selected items?"
     1257msgstr "Opravdu chcete odstranit vybrané položky?"
     1258
    12241259#: ugame.scomputer
    12251260msgctxt "ugame.scomputer"
     
    14361471msgid "View range"
    14371472msgstr "Dohled"
    1438 
  • trunk/Languages/xtactics.po

    r298 r300  
    12001200msgstr ""
    12011201
     1202#: uformplayer.sagrohigh
     1203msgctxt "uformplayer.sagrohigh"
     1204msgid "High"
     1205msgstr ""
     1206
     1207#: uformplayer.sagrolow
     1208msgctxt "uformplayer.sagrolow"
     1209msgid "Low"
     1210msgstr ""
     1211
     1212#: uformplayer.sagromedium
     1213msgctxt "uformplayer.sagromedium"
     1214msgid "Medium"
     1215msgstr ""
     1216
     1217#: uformplayer.scomputer
     1218msgctxt "uformplayer.scomputer"
     1219msgid "Computer"
     1220msgstr ""
     1221
     1222#: uformplayer.shuman
     1223msgctxt "uformplayer.shuman"
     1224msgid "Human"
     1225msgstr ""
     1226
     1227#: uformplayers.sremoveitems
     1228msgctxt "uformplayers.sremoveitems"
     1229msgid "Remove items"
     1230msgstr ""
     1231
     1232#: uformplayers.sremoveitemsquery
     1233msgctxt "uformplayers.sremoveitemsquery"
     1234msgid "Do you want to remove selected items?"
     1235msgstr ""
     1236
    12021237#: ugame.scomputer
    12031238msgctxt "ugame.scomputer"
  • trunk/UItemList.pas

    r298 r300  
    2525    Size: TPoint;
    2626    EnumStates: TStringList;
     27    VisibleIfIndex: Integer;
    2728    constructor Create;
    2829    destructor Destroy; override;
  • trunk/UPlayer.pas

    r298 r300  
    12071207  Field.EnumStates.Add(SMedium);
    12081208  Field.EnumStates.Add(SHigh);
    1209   Result.AddField(6, 'Defensive', SDefensive, dtBoolean);
     1209  Field.VisibleIfIndex := 2;
     1210  Field := Result.AddField(6, 'Defensive', SDefensive, dtBoolean);
     1211  Field.VisibleIfIndex := 2;
    12101212  Result.AddField(7, 'StartUnits', SStartUnits, dtInteger);
    12111213end;
  • trunk/xtactics.lpi

    r295 r300  
    77      <MainUnit Value="0"/>
    88      <Title Value="xtactics"/>
     9      <Scaled Value="True"/>
    910      <ResourceType Value="res"/>
    1011      <UseXPManifest Value="True"/>
  • trunk/xtactics.lpr

    r279 r300  
    2929
    3030  RequireDerivedFormResource := True;
     31  Application.Scaled:=True;
    3132  Application.Initialize;
    3233  Application.CreateForm(TCore, Core);
Note: See TracChangeset for help on using the changeset viewer.