Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanpmartell committed Jul 31, 2024
1 parent ee9f1ac commit b75b0bb
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 13 deletions.
5 changes: 2 additions & 3 deletions LittleWarGameClient/GameForm.Designer.cs

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

7 changes: 4 additions & 3 deletions LittleWarGameClient/GameForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ internal GameForm()
{
PreInitWeb();
InitializeComponent();
if (Program.LWG_FONT != null)
loadingText.Font = new Font(Program.LWG_FONT, 48F, FontStyle.Regular, GraphicsUnit.Point);
settings = new Settings();
audioMngr = new AudioManager(Text);
kbHandler = new KeyboardHandler(settings);
Expand Down Expand Up @@ -187,7 +189,6 @@ private void GameForm_Load(object sender, EventArgs e)
OverlayForm.Instance.Size = webBrowser.Size;
var webViewBounds = new Rectangle(webBrowser.PointToScreen(Point.Empty), webBrowser.Size);
OverlayForm.Instance.Location = webViewBounds.Location;
OverlayForm.Instance.AddOverlayMessage($"InitDone", new Notification("Overlay Initialized"));
}

private void webView_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e)
Expand Down Expand Up @@ -233,9 +234,9 @@ private void GameForm_Activated(object sender, EventArgs e)
{
CaptureCursor();
ResizeGameWindows();
SendKeys.Send("%{F16}"); //Alt-Tab fix for game
if (!OverlayForm.Instance.IsDisposed)
OverlayForm.Instance.Visible = true;
SendKeys.Send("%{F16}"); //Alt-Tab fix for game
}

private void GameForm_FormClosing(object sender, FormClosingEventArgs e)
Expand Down Expand Up @@ -273,7 +274,7 @@ internal async void MouseLock(bool choice)
CaptureCursor();
settings.SetMouseLock(mouseLocked);
await settings.SaveAsync();

}

internal void AddonsLoadedPostLogic()
Expand Down
4 changes: 2 additions & 2 deletions LittleWarGameClient/OverlayForm.Designer.cs

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

7 changes: 7 additions & 0 deletions LittleWarGameClient/OverlayForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,12 @@ private void OverlayForm_FormClosing(object sender, FormClosingEventArgs e)
break;
}
}

private void OverlayForm_Shown(object sender, EventArgs e)
{
TopMost = true;
textTimer.Enabled = true;
AddOverlayMessage($"InitDone", new Notification("Overlay Initialized"));
}
}
}
10 changes: 7 additions & 3 deletions LittleWarGameClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,13 @@ static void Main()
{
if (process.Id != current.Id)
{
var clientMainWindow = GetWindows(process.Handle).Where(window => window.WinTitle == "Littlewargame").First();
SetForegroundWindow(clientMainWindow.MainWindowHandle);
break;
var clientWindows = GetWindows(process.Handle).Where(window => window.WinTitle == "Littlewargame");
if (clientWindows.Count() > 0)
{
var clientMainWindow = clientWindows.First();
SetForegroundWindow(clientMainWindow.MainWindowHandle);
break;
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions LittleWarGameClient/VersionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private async void PerformCheck()
}
}

internal virtual void CheckForUpdate(object? sender, EventArgs e)
internal async virtual void CheckForUpdate(object? sender, EventArgs e)
{
if (LatestVersion != null && RequiresUpdate())
if (DialogResult.OK == MessageBox.Show("An update is available. Press OK to download it and exit the game", "Update", MessageBoxButtons.OKCancel))
Expand All @@ -69,7 +69,7 @@ internal virtual void CheckForUpdate(object? sender, EventArgs e)
GameForm.Instance.Close();
}
settings.SetLastUpdateChecked(DateTime.Now.Date);
settings.SaveAsync();
await settings.SaveAsync();
}

private bool RequiresUpdate()
Expand Down
4 changes: 4 additions & 0 deletions LittleWarGameClient/js/lwg-5.0.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -31466,6 +31466,7 @@
optionsSoundButton.id = 'optionsSoundButton';
$('#soundVolumeLabel').append(optionsSoundButton);
$('#optionsSoundButton').slider({ slide: (event, ui) => soundManager.volume.set(ui.value / 100) });
$('#optionsSoundButton').slider({ change: (event, ui) => soundManager.volume.set(ui.value / 100) });
$('#optionsSoundButton').slider('value', soundManager.volume.get() * 100);

// music volume label
Expand All @@ -31479,6 +31480,7 @@
optionsMusicButton.id = 'optionsMusicButton';
$('#musicVolumeLabel').append(optionsMusicButton);
$('#optionsMusicButton').slider({ slide: (event, ui) => musicManager.volume.set(ui.value / 100) });
$('#optionsMusicButton').slider({ change: (event, ui) => musicManager.volume.set(ui.value / 100) });
$('#optionsMusicButton').slider('value', musicManager.volume.get() * 100);

// LCG volume label
Expand All @@ -31493,6 +31495,7 @@
lcgVolumeSlider.id = 'lcgVolumeSlider';
$('#lcgVolumeLabel').append(lcgVolumeSlider);
$('#lcgVolumeSlider').slider({ slide: (event, ui) => lcgVolume.set(ui.value / 100) });
$('#lcgVolumeSlider').slider({ change: (event, ui) => lcgVolume.set(ui.value / 100) });
Initialization.onDocumentReady(() => $('#lcgVolumeSlider').slider('value', lcgVolume.get() * 100));

// scroll speed label
Expand All @@ -31506,6 +31509,7 @@
scrollSpeedButton.id = 'scrollSpeedButton';
$('#scrollSpeedLabel').append(scrollSpeedButton);
$('#scrollSpeedButton').slider({ slide: (event, ui) => interface_.scrollSpeed.set(ui.value * 50) });
$('#scrollSpeedButton').slider({ change: (event, ui) => interface_.scrollSpeed.set(ui.value * 50) });
Initialization.onDocumentReady(() => $('#scrollSpeedButton').slider('value', interface_.scrollSpeed.get() / 50));

// Setting for when messages can pop up
Expand Down

0 comments on commit b75b0bb

Please sign in to comment.