I was trying to write some simple UI in code, just to save a bit of time... Turns out it wasted more than it saved. Is it possible to created images in code? I got stuck applying a texture to a drawable. I couldn't seem to find a way to create the drawable without giving it some arbitrary json data. Is there a factory or something that would construct one for me?
Eventually, I gave up and used the csui files, but they're a pain to construct and edit by hand. For really simple UI, I'd prefer to just create it in code manually... Like in the good ol' days.
You can indeed. You don't set the value of a Drawable directly. Instead you create a DrawableDef and pass this to the Image widget:
auto widgetFactory = CSCore::Application::Get()->GetWidgetFactory();
auto resourcePool = CSCore::Application::Get()->GetResourcePool();
auto texture = resourcePool->LoadResource<CSRendering::Texture>(CSCore::StorageLocation::k_package, "Image.csimage");
CSUI::WidgetSPtr imageWidget = widgetFactory->CreateImage();
CSUI::DrawableDefCSPtr drawableDef(new CSUI::StandardDrawableDef(texture));