This repository has been archived by the owner on Jan 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
135 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,29 @@ | ||
using Eto.Forms; | ||
using System; | ||
|
||
namespace App.AdventureMaker.Core.Controls | ||
{ | ||
public class TextBoxWithButton : ControlWithButtonBase<TextBox> | ||
{ | ||
public event EventHandler<EventArgs> TextChanged; | ||
|
||
public string Text | ||
{ | ||
get => Control.Text; | ||
set => Control.Text = value; | ||
set | ||
{ | ||
Control.Text = value; | ||
TextChanged?.Invoke(this, new EventArgs()); | ||
} | ||
} | ||
|
||
public TextBoxWithButton() : base(new TextBox()) | ||
{ | ||
Button.Text = "..."; | ||
Control.TextChanged += (sender, e) => | ||
{ | ||
Text = Control.Text; | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System; | ||
|
||
namespace App.AdventureMaker.Core.Interfaces | ||
{ | ||
public interface IModifiedNotifier<DATA> | ||
{ | ||
public event Action<DATA> OnModified; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 67 additions & 10 deletions
77
App.AdventureMaker.Core/Views/Pages/LevelSets/LevelSetsPropertiesView.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,89 @@ | ||
using App.AdventureMaker.Core.Controls; | ||
using Distance.AdventureMaker.Common.Enums; | ||
using Eto.Drawing; | ||
using App.AdventureMaker.Core.Interfaces; | ||
using Distance.AdventureMaker.Common.Models; | ||
using Eto.Forms; | ||
using System; | ||
|
||
namespace App.AdventureMaker.Core.Views | ||
{ | ||
public class LevelSetsPropertiesView : StackLayout | ||
public class LevelSetsPropertiesView : StackLayout, ISaveLoad<CampaignPlaylist>, IModifiedNotifier<CampaignPlaylist> | ||
{ | ||
public event Action<CampaignPlaylist> OnModified; | ||
|
||
private bool raiseEvents = true; | ||
|
||
private readonly PropertiesListBase properties; | ||
private readonly IEditor<CampaignFile> editor; | ||
|
||
private readonly TextBox nameBox; | ||
private readonly TextBox descriptionBox; | ||
private readonly TextBoxWithButton iconBox; | ||
private readonly GuidLabel guidBox; | ||
|
||
public LevelSetsPropertiesView() | ||
public LevelSetsPropertiesView(IEditor<CampaignFile> editor_) | ||
{ | ||
editor = editor_; | ||
|
||
//Style = "no-padding"; | ||
Orientation = Orientation.Vertical; | ||
HorizontalContentAlignment = HorizontalAlignment.Stretch; | ||
|
||
properties = new PropertiesListBase(); | ||
|
||
properties.AddRow("Name", new TextBox()); | ||
properties.AddRow("Description", new TextBox()); | ||
properties.AddRow("Icon", new TextBoxWithButton()); | ||
properties.AddRow("Playlist locking", new EnumDropDown<PlaylistUnlock>()); | ||
properties.AddRow("Individual level locking", new EnumDropDown<LevelUnlock>()); | ||
properties.AddRow("Difficulty rating", new EnumDropDown<Difficulty>()); | ||
properties.AddRow("Name", nameBox = new TextBox()); | ||
properties.AddRow("Description", descriptionBox = new TextBox()); | ||
properties.AddRow("Icon", iconBox = new TextBoxWithButton()); | ||
properties.AddRow("Unique ID", guidBox = new GuidLabel()); | ||
//properties.AddRow("Playlist locking", new EnumDropDown<PlaylistUnlock>()); | ||
//properties.AddRow("Individual level locking", new EnumDropDown<LevelUnlock>()); | ||
//properties.AddRow("Difficulty rating", new EnumDropDown<Difficulty>()); | ||
|
||
properties.CompleteRows(); | ||
|
||
Items.Add(new StackLayoutItem(properties) { Expand = false }); | ||
|
||
nameBox.TextChanged += NotifyModified; | ||
descriptionBox.TextChanged += NotifyModified; | ||
iconBox.TextChanged += NotifyModified; | ||
guidBox.TextChanged += NotifyModified; | ||
} | ||
|
||
private void NotifyModified(object sender, EventArgs e) | ||
{ | ||
if (!raiseEvents) return; | ||
|
||
var playlist = new CampaignPlaylist(); | ||
SaveData(playlist); | ||
OnModified?.Invoke(playlist); | ||
} | ||
|
||
public void LoadData(CampaignPlaylist playlist) | ||
{ | ||
if (playlist != null) | ||
{ | ||
raiseEvents = false; | ||
|
||
nameBox.Text = playlist.name; | ||
descriptionBox.Text = playlist.description; | ||
iconBox.Text = playlist.icon; | ||
guidBox.Text = playlist.guid; | ||
|
||
raiseEvents = true; | ||
} | ||
} | ||
|
||
public void SaveData(CampaignPlaylist playlist) | ||
{ | ||
//raiseEvents = false; | ||
|
||
playlist.name = nameBox.Text; | ||
playlist.description = descriptionBox.Text; | ||
playlist.icon = iconBox.Text; | ||
playlist.guid = guidBox.Text; | ||
|
||
//raiseEvents = true; | ||
|
||
//NotifyModified(null, null); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters