Skip to content

Commit

Permalink
game manager updates
Browse files Browse the repository at this point in the history
added delete game function
  • Loading branch information
xantari committed Jan 22, 2021
1 parent 57e2d22 commit 113dc3e
Show file tree
Hide file tree
Showing 10 changed files with 268 additions and 45 deletions.
42 changes: 30 additions & 12 deletions PinCab.Configurator/AddEditGameForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 61 additions & 4 deletions PinCab.Configurator/AddEditGameForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -18,12 +19,15 @@ namespace PinCab.Configurator
public partial class AddEditGameForm : Form
{
private FrontEndGameViewModel _setting { get; set; }
private string originalFileName { get; set; }
private FrontEndManager _manager { get; set; }
public AddEditGameForm(FrontEndGameViewModel setting, FrontEndManager manager)
private string _databaseFile { get; set; }
public AddEditGameForm(FrontEndGameViewModel setting, string databaseFile, FrontEndManager manager)
{
InitializeComponent();
_setting = setting;
_manager = manager;
_databaseFile = databaseFile;
LoadForm();
}

Expand All @@ -44,14 +48,24 @@ private void LoadForm()
txtSeconds.Text = _setting.SecondsPlayed.ToString();
txtAdded.Text = _setting.DateAdded.ToString();
txtModified.Text = _setting.DateModified.ToString();
txtAlternateExe.Text = _setting.AlternateExe;
txtComment.Text = _setting.Comment;
txtGameUrl.Text = _setting.TableFileUrl;
chkHideBackglass.Checked = _setting.HideBackglass;
chkHideDmd.Checked = _setting.HideDmd;
chkHideTopper.Checked = _setting.HideTopper;
chkEnabled.Checked = _setting.Enabled;
chkFavorite.Checked = _setting.Favorite;

//Load the alternate exe list
if (_setting.FrontEnd.System == FrontEndSystem.PinballX)
{
var system = _manager.PinballXSystems.FirstOrDefault(c => c.DatabaseFiles.Contains(_databaseFile));
cmbAlternateExe.Items.AddRange(system.Executables.ToArray());
}
if (string.IsNullOrEmpty(_setting.AlternateExe))
cmbAlternateExe.SelectedItem = "<default>";
else
cmbAlternateExe.SelectedItem = _setting.AlternateExe;
}

private FrontEndGameViewModel GetSettingFromControls()
Expand Down Expand Up @@ -84,8 +98,11 @@ private FrontEndGameViewModel GetSettingFromControls()
if (success)
_setting.DateModified = result;
}

_setting.AlternateExe = txtAlternateExe.Text.IfEmptyThenNull();

if (cmbAlternateExe.SelectedText == "<default>" || string.IsNullOrEmpty(cmbAlternateExe.SelectedText))
_setting.AlternateExe = null;
else
_setting.AlternateExe = cmbAlternateExe.SelectedText.IfEmptyThenNull();
_setting.Comment = txtComment.Text.IfEmptyThenNull();
_setting.TableFileUrl = txtGameUrl.Text.IfEmptyThenNull();
_setting.HideBackglass = chkHideBackglass.Checked;
Expand All @@ -107,5 +124,45 @@ private void btnSave_Click(object sender, EventArgs e)
Close();
}

private void btnSelectFile_Click(object sender, EventArgs e)
{
using (OpenFileDialog fileDialog = new OpenFileDialog())
{
fileDialog.Filter = "All files (*.*)|*.*|VPX Files|*.vpx|FPT Files|*.fpx|VPT Files|*.vpt";
fileDialog.FilterIndex = 1;
fileDialog.RestoreDirectory = true;
var result = fileDialog.ShowDialog();
if (result == DialogResult.OK)
{
var fi = new FileInfo(fileDialog.FileName);
var endIndex = fi.Name.LastIndexOf(fi.Extension);
originalFileName = txtTableName.Text;
txtTableName.Text = fi.Name.Substring(0, endIndex);
}
}
}

private void btnIpdbUrl_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(txtIpdb.Text))
System.Diagnostics.Process.Start("https://www.ipdb.org/machine.cgi?id=" + txtIpdb.Text);
}

private void btnFillFromIpdb_Click(object sender, EventArgs e)
{

}

private void btnGameUrl_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(txtGameUrl.Text))
System.Diagnostics.Process.Start(txtGameUrl.Text);
}

private void btnDatabaseBrowser_Click(object sender, EventArgs e)
{
var form = new DatabaseBrowserForm();
var result = form.ShowDialog();
}
}
}
29 changes: 15 additions & 14 deletions PinCab.Configurator/GameManagerForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 113dc3e

Please sign in to comment.