void Initialize() { const Box box; std::stringstream s; s<<box; Gui* gui = world.CreateSystem<Gui>(); world.CreateSystem<ClickColorSystem>(); gui->Setup("images.png", "images.xml", Context().Viewport(), Input); gui->CreateFont("Font.fnt", "Font"); auto control = gui->CreateControl(0, "Box", 300); control->AddComponent<Draggable>(); }
void Initialize() { GameObject* root = world.CreateRoot(); Gui* gui = root->CreateSystem<Gui>(); root->CreateSystem<LayoutSystem>(); gui->Setup("images.png", "images.xml", Context().Viewport()); box = gui->CreateControl(root, "Box", 100, 300); box->AddComponent<Draggable>(); box->AddComponent<Layouter>()->ChildrenLayoutMode = Layouter::LayoutMode::Vertical; box->GetComponent<Layouter>()->SetAll(300); for(int i=0; i<4; i++) { GameObject* row = gui->CreateControl(box, "Box"); row->AddComponent<Layouter>()->Min = {300, 1}; row->GetComponent<Layouter>()->Max = {300.0f, static_cast<float>((i == 1 ? 60 : 20))}; row->GetComponent<Layouter>()->Desired = {300.0f, static_cast<float>((i == 1 ? 60 : 20))}; row->GetComponent<Layouter>()->ChildrenLayoutMode = Layouter::LayoutMode::Horizontal; AddTextBox(row, gui, {50, 20}, {50,20}); AddTextBox(row, gui, {100, 20}, {5000,20}); //AddTextBox(row, gui, {200, 20}, {300,20}); } dragger = gui->CreateControl(root, "Box", 100, 30); dragger->AddComponent<Draggable>(); //auto font = gui->CreateFont("Font.fnt", "Font"); //gui->CreateClipper(box, true); //auto label = gui->CreateLabel(box, 100, 200, font, "Hej med dig", 50); //gui->CreateClipper(box, false); /* GameObject* root = world.CreateRoot(); Selectable* sel1 = 0; { GameObject* object = root->CreateChild(); sel1 = object->AddComponent<Selectable>(); sel1->Selected.Changed.Bind(this, &Game::SelectedChanged, object); std::cout << "1. empty = " << (sel1->Selected.Changed.Empty() ? "true" : "false") << std::endl; object->Remove(); } world.Update(0); Selectable* sel2 = 0; { GameObject* object = root->CreateChild(); sel2 = object->AddComponent<Selectable>(); //sel2->Selected.Changed.Bind(this, &Game::SelectedChanged, object); std::cout << "2. empty = " << (sel2->Selected.Changed.Empty() ? "true" : "false") << std::endl; object->Remove(); } if (sel1 == sel2) { std::cout << "Same" << std::endl; } Component cDefault = Component(); //cDefault.Value = 123; Component comp1 = cDefault; comp1.Value.Changed.Bind(this, &Game::SelectedChanged, (GameObject*)0); comp1.Value = cDefault.Value; comp1 = cDefault; { } */ }