GithubHelp home page GithubHelp logo

chillerdragon / ddnet_hotui Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 44 KB

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

Makefile 8.75% C++ 84.98% C 6.27%
ddnet ddnet-client hot-reload hot-reloading sample teeworlds teeworlds-client

ddnet_hotui's Introduction

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

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 [email protected]:ChillerDragon/ddnet_hotui.git
git clone [email protected]: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.

ddnet_hotui's People

Contributors

chillerdragon avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.