WIP enemy editor
This commit is contained in:
55
EstusShots.Gtk/Pages/EnemiesPage.cs
Normal file
55
EstusShots.Gtk/Pages/EnemiesPage.cs
Normal file
@@ -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<Enemy> _enemiesControl;
|
||||
|
||||
private void InitEnemiesPage()
|
||||
{
|
||||
var columns = new List<DataColumn>
|
||||
{
|
||||
new DataColumnText(nameof(Enemy.Name)),
|
||||
new DataColumnBool(nameof(Enemy.Boss)){Title = "Is Boss?"},
|
||||
new DataColumnBool(nameof(Enemy.Defeated)){Title = "Defeated?"}
|
||||
};
|
||||
_enemiesControl = new BindableListControl<Enemy>(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");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user