Skip to content

Latest commit

 

History

History
75 lines (53 loc) · 2.68 KB

README.md

File metadata and controls

75 lines (53 loc) · 2.68 KB

ddnet_hotui

Iterate in ddnet ui development without rebooting the client. CUIRect hot reloading.

how it looks like when it works

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

output

ddnet_tee7_sample.mp4

ddnet_hotui_ingame.gif

full on video tutorial on how to use it

ddnet hotui video tutorial

folder setup

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.

how to link up the code

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

void *handle = dlopen("../../ddnet_hotui/sample.so", RTLD_LAZY);
is correct you should see instant ui changes in your running client.

traps

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.