Iterate in ddnet ui development without rebooting the client. CUIRect hot reloading.
A old less fancy sample implementation can be seen here.
Here is how your development with hot reloading could look like:
ddnet_ui_hotreloading.mp4
ddnet_tee7_sample.mp4
The examples assume you have the following setup.
git clone git@github.com:ChillerDragon/ddnet_hotui.git
git clone git@github.com:ddnet/ddnet.git --recursive
So a folder called ddnet/ with the ddnet source code. And a folder with this repo right next to it. It further more expects you to run the client from ddnet/build/DDNet
So in the end it should look like this (simplified)
.
├── ddnet
│ ├── build
│ │ └── DDNet
│ └── src
└── ddnet_hotui
├── Makefile
└── sample.cpp
If you nest it differently or named things differently. You have to adjust the paths in the sample.
Add this to the top of your ddnet client code C++ file
#include "../../ddnet_hotui/loader.h"
And this in the method where you want to do hot reloading
// void CMenus::RenderSettings(CUIRect MainView)
// {
HotCuiRects(MainView);
// }
Also when compiling ddnet you need to make sure the -rdynamic
flag is set.
So somewhere in your CMakeLists.txt add this line
add_cxx_compiler_flag_if_supported(OUR_FLAGS_LINK -rdynamic)
or alternatively you can run this cmake .. -DCMAKE_CXX_FLAGS=-rdynamic
Then you can play around in the sample.cpp
file and run make
when you are done. If the path here
Line 11 in 2e501b9
Do not use static
variables in your hot reloaded code.
They will be confusing to debug. They will be reset to their initial value on every hot reload.