Skip to content
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

Allow multiple MonoGameContentControl #9

Merged
merged 5 commits into from
May 20, 2024

Conversation

FaustVX
Copy link
Contributor

@FaustVX FaustVX commented Jun 19, 2022

  • Updated to .NET6
  • Nullable enabled
  • Added the Components system from MonoGame
  • Multiple MonoGameContentControl
    • In the same window
    • In multiple windows
  • Removed useless whitespaces

@damian-666
Copy link

thanks.. im forked it an merging your changes to my mg3.81 version that has a shared content core... ill put it somewher.. i use tabbed dialogs and now im getting weird isseus with sharp still whne i put this i my ribbon versoin.. i tried marc stans version but its too complex and it has the sample problem, SetSharedHandle method not found, in sharp DX only when i put in my ribbon tab....anywasy this is stronger version...thx... ill put it somewhere even if its not merged...it seems more robust.. tabbed/ docking or custom window calss windon dialogs are because it unloads on each activation... i dont evne remember how got around it last time... but its might leak that donest matter.

@damian-666
Copy link

hey thanks!!! i took your the PR for the wpf contorl , which is in a tagged dialog , dockable i n mine ( worse thatn just doing two instances) merge with mine, stuck, in old docking ribbon level editor thats net6- windows, but has net 4.8 legacy controls , uses a shared net 6 gamecore lib, shared assets, and my MG view works again.. now i FINALLY have my tooling up to Net 6 LTS with no netstandard or 4.8.. in my own code.. multiple tabbed dialogs is still weird and has issues and or leaks.... becasue it unloads and disposes... Marck stan way is to let it leak... but his way is way too complex.. i dont use the GameComponent model.. or input..

before i got a Method not found in
CreateRenderTarget. GetSharedHandle..... and its wanst even stepping in to the content control ovveride.. so i spend weeks and tried mark stans version but its too complex. i didnt wanan build MG nad sharp DX.. but now i dont have to .. i just dropped ur version on mine and made it stretch, to overlay my WPF viewport adn now i mix wpf adorners with MG graphics.. perfecto.... the 60 fps limit is gone too if i wanna run my game loop at 2000 fps i can..

@FaustVX
Copy link
Contributor Author

FaustVX commented Sep 18, 2022

Hi @damian-666
To be honest, I didn't fully understand what you're saying.
I'm not a native English speaker.

So if I understand what you're saying, is that you've had a hard time to make it works with your project, but at the end everything work very well (200fps is really a lot 😄 )
But I don't understand if the issue was on my side, or in your project.

@damian-666
Copy link

damian-666 commented Sep 18, 2022

. not sure exacly why but its generally looks like a proper upgrade... with good coding practices. Merci beaucoup!!! :) netcore6 wpf is is little different and its was a mysterious SharpDX error...
après trop de nuits d'enfer, i finally gave up, came back weeks later . tried ur code, it went away and i could at least see the render target as soon as i dropped your 4 core control files on.

.anywasy its a generallly good PR upgrade and good codeing practice. i dont have nullable context on so i just get a warning ,no problem.

if you are curious about the fps i mentioned i meant on my backgroud update thread as i don't use the monogame DRaw and Update Components or call Monogaem update because its on the UI thread.. ... so i #ifdef that out of your code. i only use the draw call.

the crazy fast update, its still drawing at 60 fps but
i can update my physics animation at even 2000 fps with net6 , on a background thread..., but draw at 60 fps the llast finished frame using the lockless producer/ consumer pattern... .. and put the wpf editing grips and adorners stuff overlaid.... . so the mgview content control in hte same canvas , if the transforms are aligned , it lets me do that instead of using WPF to draw the graphics. I still have to adjust the viewports and size but at least i can see what im doing now thx..

@FaustVX
Copy link
Contributor Author

FaustVX commented Sep 18, 2022

. not sure exacly why but its generally looks like a proper upgrade... with good coding practices. Merci beaucoup!!! :)

.anywasy its a generallly good PR upgrade and good codeing practice. i dont have nullable context on so i just get a warning ,no problem.

Thanks ;p

So I went to your GH profile, and in fact, what you're saying is that you've had to put my modifications in your own version of MonoGameWPF ? Am I correct ?

@damian-666
Copy link

damian-666 commented Sep 18, 2022 via email

@damian-666
Copy link

damian-666 commented Sep 18, 2022 via email

@DavidFidge
Copy link
Contributor

I didn't see this before I opened my own pull request to update to MonoGame 3.8.1 and .Net 6. You went a bit further with nullables and the like. Looks very clean.

@damian-666
Copy link

damian-666 commented Apr 23, 2023 via email

@damian-666
Copy link

damian-666 commented Apr 23, 2023 via email

README.md Outdated
### To Create a new Window

```xaml
<monoGameControls:MonoGameContentControl Window="Set this value" />

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you actually set the Window property in XAML? I'm trying to get this going but I'm getting stuck here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • You can use the x:Reference tag to name it:
<Window  x:Name="This"> <!-- Type your control ID here -->
    <monoGameControls:MonoGameContentControl Window="{x:Reference This}" /> <!-- Retype it here -->
</Window>
  • Or use any property.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for teaching me about {x:Reference} :) I'm pretty new to WPF and that came in super handy for a lot of stuff

@joumasehare
Copy link

This definitely works for multiple Windows as well as multiple Viewports in one window. All in the same process.

See my proof attached
image

@Gandifil Gandifil merged commit dea0c00 into craftworkgames:master May 20, 2024
@damian-666
Copy link

Notes: the Avalonia.Dock is being fixed now. the redocking is still broken. im going to wait a bit.,

this addresses a lot of issues and i try to see if there is overlap and if just waiting for someelse to do it in a very basic mimimal was is happening. its not. but the code they sue and architectuer is worth a look.

this is about moving toward avalonia, and also about GraphicsDeviceService , the MVVM itself, is now bound to a Game class.
the original was cound to a MonoGameViewModel base class thats how i would like to keep my branch since it have my own key mape and render loop , models and timers.

Playing Songs in is still one at a time. you need a window handle to parent the Medial player. SoundEffects you dont

There should be a control that just renders to the avalonia system and does not require binding to a game or any Binding..

for an out of game IDE i have scaffolding, i might use different UI. the other choice is a full in game render like ImgUI. or bother.

one comment if you undock windows you might want to create a backing surface as big was the desktop. to share it. this was dont in markstans over-engineered version. it has mouse capture and text and too much.

for my game i take input from avalonia and just sysc render. thats it.

now im trying to get an avalonia one as a sample , the ones i see aer using swapchain and or anopenGL with an FBO
so no passing bufferes to the GPU.. or writeable bitmap is needed.

but id like to use a GRaphicsDeviceService like this sample doest.  .. here it is being done:

Macabresoft/Macabre2D@1a4d513

https://github.com/Macabresoft/Macabre2D/blob/7ab211ead720b00535a46d5d05197159704e46c0/UI/AvaloniaInterop/MonoGameControl.cs

https://github.com/nkast
i i see a vulcan version and a dxverion. i would like to use the KNI verion for openGL desktop as some point.
it has a better shader mojoshader transpiler . for fx to opengl

silk has an opengl binding.
https://github.com/wieslawsoltes/Dock/issues but the redock is still an issue. . there is a new release.

also the sample of docking is being fixed now..

there is no need to have a game directed class and the Components used by mark stan, and added inths..

i would need a thin launcher and a shared view module. on for dx , one for win GL, and linux and ios.

note.., thsi might go in another vault, i don't want to merge any UI stuff , use Game class or GameComponent, too tightly coupled.
or
like the key maps but others might want to fork it.

my IDE has it own general keymap. gamepad, thats broken out separately ,, the control is use to get into a avalonica window, shared the same backing , be drawn first , annotated over with avalonia UI.. on the render class i copy the vectors,, as immtupile map to sprite, etc, wth rendertargets. then aligned the viewport /window and draw. on the update i set the viewport and the window to the current zoom.

please sponsor avalonia guys wike Wieslaw the community has stuff but his projects are way too many .. like Dock2d.
it has everything an IDE would want..

the KNI branch is good and the monogame branch is is active again but supports console so it harder to maintain
https://github.com/kniEngine/kni/commits/main/

there is compute branch but not there is a ComputeNet project by Microsoft. that is more like cude

Stride is moving to Avalonia _ the same dock ( i linked)
but the parts are abir tightly coupled.. the ECS, the undo redo in the viewdole and edit code is mixed with the view code viewModel, tht might be ok.

in stride they bind the viewodels to things like
SceneEditorViewModel
AssetCompositeHierarchyEditorViewModel
SceneEditorGame

as long s it implemtns IUpdate, ContentLoad, IDraw it shouild be bindible to a class like that. a

MGVVMBase or something.

string is a way from having this working. its very complex. for me i like Core2D but i dont konw if dock will get merged to thata.,

so just adding this so peple aer awarer what others are working on ...
this is a dicksterDock allso but its maintained by one person and its has more feature but not as close to the core Avalonia samples and community.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants