-
Notifications
You must be signed in to change notification settings - Fork 432
Remove IMainFormForApiInit. #4582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| if (mainForm is MainForm mainAsForm) | ||
| { | ||
| formsLib.DialogParent = mainAsForm; | ||
| formsLib.OwnerForm = mainAsForm; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are one and the same semantically.
BizHawk/src/BizHawk.Client.Common/IDialogParent.cs
Lines 5 to 6 in 2363d5e
| /// <remarks>In a WinForms app, inheritors must also inherit <c>System.Windows.Forms.IWin32Window</c>.</remarks> | |
| public interface IDialogParent |
As a
Form, MainForm is the owner of any windows that are created by forms.newform. As an IDialogParent, MainForm is the owner of the file picker dialog when forms.openfile is called. In either case the object is only being used for the window handle encoded within it.And if we change UI framework,
FormsLuaLibrary can cast to the relevant window handle type. This class shouldn't be concerned with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it (FormsLuaLibrary) should only use a IDialogParent property, and cast that to Form?
I was imagining if we change UI framework, FormsLuaLibrary would not be used but another equivalent one would.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tools don't seem to have any way to reference the main form as IDialogParent. Rather than assume it is one, I have made LuaConsole pass itself to LuaLibraries for the IDialogParent reference.
Also changed FormsLuaLibrary to use it as IWin32Window instead of Form.
| ApiContainer apiContainer) | ||
| { | ||
| _apiContainer = ApiManager.RestartLua(newServiceProvider, LogToLuaConsole, _mainForm, _displayManager, _inputManager, _mainForm.MovieSession, _mainForm.Tools, config, emulator, game); | ||
| _apiContainer = apiContainer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now this is an interesting idea. I'm not sure if it's semantically sound, but the call order seems the same so it should be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not convinced that the restart logic is correct, but yeah this should be equivalent to what is already there. And I see no reason why LuaLibraries would need to be responsible for constructing the API instances or ApiContainer.
Btw this is something my other PR does too.
c99881d to
a523387
Compare
@YoshiRulz
Doing this is also good for my Lua PR, since it currently still has LuaFormsLibrary assuming that the main form reference is a
IDialogParent.