diff --git a/EstusShots.Gtk/Dialogs/Dialogs.glade b/EstusShots.Gtk/Dialogs/Dialogs.glade deleted file mode 100644 index 9634ff1..0000000 --- a/EstusShots.Gtk/Dialogs/Dialogs.glade +++ /dev/null @@ -1,174 +0,0 @@ - - - - - - False - Player - False - True - center-on-parent - True - dialog - center - - - - - - False - vertical - 2 - - - False - end - - - gtk-save - True - True - True - True - - - - True - True - 0 - - - - - gtk-cancel - True - True - True - True - - - True - True - 1 - - - - - False - False - 0 - - - - - True - False - - - True - False - 10 - 10 - 5 - 7 - - - True - False - end - Name - - - 0 - 0 - - - - - True - False - end - Alias - - - 0 - 1 - - - - - True - True - - - 1 - 0 - - - - - True - True - - - 1 - 1 - - - - - Anonymous - True - True - False - True - - - 1 - 3 - - - - - True - False - end - Hex ID - - - 0 - 2 - - - - - True - True - 4 - 0x00 - alpha - - - 1 - 2 - - - - - - - - -1 - - - - - True - True - 1 - - - - - - diff --git a/EstusShots.Gtk/Dialogs/EnemyEditor.cs b/EstusShots.Gtk/Dialogs/EnemyEditor.cs new file mode 100644 index 0000000..35b0ee9 --- /dev/null +++ b/EstusShots.Gtk/Dialogs/EnemyEditor.cs @@ -0,0 +1,48 @@ +using System.Collections.Generic; +using EstusShots.Gtk.Controls; +using EstusShots.Shared.Dto; +using Gtk; +using UI = Gtk.Builder.ObjectAttribute; + +namespace EstusShots.Gtk.Dialogs +{ + public class EnemyEditor : DialogBase + { + [UI] private readonly Entry _nameEntry = null; + [UI] private readonly CheckButton _isBossCheckButton = null; + [UI] private readonly SearchEntry _searchSeasonEntry = null; + [UI] private readonly TreeView _selectedSeasonsTreeView = null; + + private BindableListControl _selectedSeasonsControl; + private readonly List _allSeasons; + private readonly EntryCompletion _allSeasonsCompletion; + + public EnemyEditor(Window parent, Enemy enemy, List seasons) : + base(parent, new Builder("EnemyEditor.glade")) + { + EditObject = enemy; + _allSeasons = seasons; + + var columns = new List + { + new DataColumnText(nameof(Season.DisplayName)) {Title = "Seasons"} + }; + _selectedSeasonsControl = + new BindableListControl(columns, nameof(Season.SeasonId), _selectedSeasonsTreeView); + + _allSeasonsCompletion = new EntryCompletion(); + + _searchSeasonEntry.Completion = new EntryCompletion(); + } + + protected override void LoadToModel() + { + throw new System.NotImplementedException(); + } + + protected override void LoadFromModel() + { + throw new System.NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/EstusShots.Gtk/Dialogs/Glade/EnemyEditor.glade b/EstusShots.Gtk/Dialogs/Glade/EnemyEditor.glade new file mode 100644 index 0000000..4e8d279 --- /dev/null +++ b/EstusShots.Gtk/Dialogs/Glade/EnemyEditor.glade @@ -0,0 +1,174 @@ + + + + + + + False + Enemy + False + True + center-on-parent + 350 + 250 + True + dialog + center + + + + + + False + vertical + 2 + + + False + end + + + gtk-save + True + True + True + True + + + + True + True + 0 + + + + + gtk-cancel + True + True + True + True + + + True + True + 1 + + + + + False + False + 0 + + + + + True + False + 10 + 10 + 5 + 7 + + + True + False + end + Name + + + 0 + 0 + + + + + True + True + + + 1 + 0 + + + + + Is Boss + True + True + False + True + True + + + 1 + 1 + + + + + True + False + end + Seasons + + + 0 + 2 + + + + + True + True + edit-find-symbolic + False + False + entrycompletion1 + + + 1 + 2 + + + + + True + True + True + True + in + + + True + True + horizontal + + + + + + + + 1 + 3 + + + + + + + + + + + True + True + 1 + + + + + + diff --git a/EstusShots.Gtk/MainWindow.cs b/EstusShots.Gtk/MainWindow.cs index 1990d5d..8716d9a 100644 --- a/EstusShots.Gtk/MainWindow.cs +++ b/EstusShots.Gtk/MainWindow.cs @@ -42,6 +42,7 @@ namespace EstusShots.Gtk InitSeasonsPage(); InitEpisodesPage(); InitBaseDataPage(); + InitEnemiesPage(); // The episodes page is not shown, as long as no season is selected EpisodesPage.Hide(); diff --git a/EstusShots.Gtk/MainWindow.glade b/EstusShots.Gtk/MainWindow.glade index 068ce85..72ab23e 100644 --- a/EstusShots.Gtk/MainWindow.glade +++ b/EstusShots.Gtk/MainWindow.glade @@ -61,11 +61,17 @@ True False + 5 + 5 + 5 + 5 vertical + 5 True False + 5 end @@ -235,27 +241,68 @@ - + True False + 5 + 5 + 5 + 5 vertical + 5 - - - - + True False - Enemies go here + 5 + end + + + New Enemy + True + True + True + + + True + True + 0 + + + + + + + + False True - 1 + 0 - + + True + True + in + + + True + True + horizontal + + + + + + + + True + True + 1 + @@ -420,6 +467,7 @@ True False + 5 start diff --git a/EstusShots.Gtk/Pages/BaseDataPage.cs b/EstusShots.Gtk/Pages/BaseDataPage.cs index d022b1b..cb28eb0 100644 --- a/EstusShots.Gtk/Pages/BaseDataPage.cs +++ b/EstusShots.Gtk/Pages/BaseDataPage.cs @@ -16,7 +16,6 @@ namespace EstusShots.Gtk [UI] public readonly TreeView PlayersTreeView = null; [UI] public readonly Button NewPlayerButton = null; [UI] public readonly Button NewDrinkButton = null; - [UI] public readonly TreeView DrinksTreeView = null; private BindableListControl _playersControl; diff --git a/EstusShots.Gtk/Pages/EnemiesPage.cs b/EstusShots.Gtk/Pages/EnemiesPage.cs new file mode 100644 index 0000000..f6c2e53 --- /dev/null +++ b/EstusShots.Gtk/Pages/EnemiesPage.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using EstusShots.Gtk.Controls; +using EstusShots.Gtk.Dialogs; +using EstusShots.Shared.Dto; +using EstusShots.Shared.Models.Parameters; +using Gtk; +using UI = Gtk.Builder.ObjectAttribute; + +namespace EstusShots.Gtk +{ + internal partial class MainWindow + { + [UI] private readonly Box _enemiesPage = null; + [UI] private readonly TreeView _enemiesTreeView = null; + [UI] private readonly Button _newEnemyButton = null; + + private BindableListControl _enemiesControl; + + private void InitEnemiesPage() + { + var columns = new List + { + new DataColumnText(nameof(Enemy.Name)), + new DataColumnBool(nameof(Enemy.Boss)){Title = "Is Boss?"}, + new DataColumnBool(nameof(Enemy.Defeated)){Title = "Defeated?"} + }; + _enemiesControl = new BindableListControl(columns, nameof(Enemy.EnemyId), _enemiesTreeView); + + _newEnemyButton.Clicked += NewEnemyButtonOnClicked; + } + + private void NewEnemyButtonOnClicked(object sender, EventArgs e) + { + + } + + private async void ReloadEnemies() + { + var res = await Task.Factory.StartNew(() + => Client.Enemies.GetEnemies(new GetEnemiesParameter()).Result); + if (!res.OperationResult.Success) + { + InfoLabel.Text = $"Refresh failed: {res.OperationResult.ShortMessage}"; + ErrorDialog.Show(res.OperationResult); + return; + } + + _enemiesControl.Items = res.Data.Enemies; + _enemiesControl.DataBind(); + Info("Enemy list refreshed"); + } + } +} \ No newline at end of file