Jump to content

Slastraf

Developers
  • Posts

    705
  • Joined

  • Last visited

Posts posted by Slastraf

  1. How to use it ?
    Yesterday it seemed to work by setting subnode->SetParent(nullptr); then it would hide the whole tree but today I get an error.
    I made code to reproduce it, can replace lines 74-76 in the default project main.
     

    
    	auto tree2 = CreateTreeView(border, border, 280, subpanel3->ClientSize().y - border * 2, subpanel3, TREEVIEW_DRAGANDDROP | TREEVIEW_DRAGINSERT);
    	tree2->SetLayout(1, 0, 1, 1);
    	
    	auto subnode2 = tree2->root->AddNode("Node 1");
    	for (int n = 1; n < 10; ++n)
    	{
    		subnode2->AddNode("Subnode " + String(n));
    	}
    //error here
    	subnode2->SetParent(nullptr);

    BTW, also happens with SetParent(NULL);

  2. Hmm hatte früher auch oft Probleme mit den Grafiktreibern, versuch die immer aktuell zu halten vielleicht hast du jetzt gerade auch keine aktuelle Version drauf, und die offiziellen von Nvidia. Ich benutze jedoch Windows.

    Und bitte benutzte ab jetzt deepl.com/translator anstatt google Übersetzer und stelle deine Frage nochmal neu ?

  3. Hello,

    I am yet challenged by adding nodes, namely a subnode to a selected node.
     

    shared_ptr<TreeViewNode> *currentNode;
    ...
    
    case EVENT_WIDGETSELECT:
    	...	
    	if(event.extra->As<TreeViewNode>()) 
    		*currentNode = event.extra->As<TreeViewNode>();
         ...
    
    currentNode->addNode(); // currentNode has no member addNode()

    I think the code is self explainatory. How do I make this right ?

    regards

  4. Hello,
    it would be really cool to have a system that automatically serializes the application state for later use.
    Say you make some array and a correlating treeNode in runtime then click on save and it will detect all the things the users has put in and just brute force saves all the things that are going on and load them for later use.

    Regards
     

  5. Hey there,

    the following code example will make a text field which is rather big and can be applied to the example project if replaced by line  141 and following.
     

    
    	auto styleTextArea = CreateTextField(border, border + 40, subpanel2->ClientSize().x - 2 * border, subpanel2->ClientSize().y - 2 * border - 40, subpanel2);
    	styleTextArea->SetAlignment(1, 1, 1, 1);
    	styleTextArea->SetText("		#my_iframe{\n		position: absolute;\n		top: 0px;\n		left: 0px;\n		width: 100%;\n		height: 100%;\n		border:0;\n		}\n\n		#hide_button, #show_button{\n		position: absolute;\n		width: 100px;\n		height: 30px;\n			background-color: DodgerBlue;\n		color: white;\n			text-align: center;\n			line-height: 30px;\n		cursor: pointer;\n		}\n\n			#hide_button{\n		left: 10px;\n		}\n\n			#show_button{\n		left: 120px;\n		}\n");

    In the latter code example i put the whole text thing in one line , but using my original approach made it even buggier : 
     

    
    #define MULTI_LINE_STRING(a) #a
    
    struct styleTextTemplate{
    	const char* text = MULTI_LINE_STRING(
    		#my_iframe{\n
    		position: absolute;\n
    		top: 0px;\n
    		left: 0px;\n
    		width: 100%;\n
    		height: 100%;\n
    		border:0;\n
    		}\n\n
    
    		#hide_button, #show_button{\n
    		position: absolute;\n
    		width: 100px;\n
    		height: 30px;\n
    			background-color: DodgerBlue;\n
    		color: white;\n
    			text-align: center;\n
    			line-height: 30px;\n
    		cursor: pointer;\n
    		}\n\n
    
    			#hide_button{\n
    		left: 10px;\n
    		}\n\n
    
    			#show_button{\n
    		left: 120px;\n
    		}\n
    		);
    };
    
    // and use setText
    auto styleTextArea = CreateTextField(border, border + 40, subpanel2->ClientSize().x - 2 * border, subpanel2->ClientSize().y - 2 * border - 40, subpanel2);
    	styleTextArea->SetAlignment(1, 1, 1, 1);
    	styleTextTemplate style;
    	styleTextArea->SetText(style.text);

    EDIT: Sorry wrong category

  6. 1 minute ago, Optimus Josh said:

    Didn't we just say the exact same thing two different ways? :huh:

    FindChild implies you would need to know there is a parent. But if you dont know the parent you would need to call it from the root, then it collapses on itself and it becomes a Find() function. Now if you had a find function there needs to be a unique identifier for each widget which the user could set and dont need to worry about all of this.

    • Confused 1
  7. Hello,

    It is rather hard to remove an item from a TreeView if its not on the lowest subnode. 
     

    auto it = std::find(itemFolder->begin(), itemFolder->end(), itemClass);
    if (it != itemFolder->end())
    	itemFolder->erase(it);
    subnode->ClearNodes();
    // rebuild nodes
    for each (itemClass k in *itemFolder)
    {
    	subnode->AddNode(k.info);
    }

    This for example works okay if you rebuild the tree in the following but you won't be able to remove if it is in a top treenode.

    a.PNG

  8. Hello,
    i don thave much time to make this but here is a bug report about making a new window in U.A.K.
    Therefore I am posting the whole script I got, and will tell you where the important lines are.
     

    #include "pch.h"
    #include <iostream>
    #include <fstream>
    
    using namespace UltraEngine;
    string compileAndWrite(fstream& file, string& contentsOfWebsite);
    string compileAndExport(string& contents);
    
    
    bool RescaleUI(const Event& event, shared_ptr<Object> extra)
    {
    	auto ui = dynamic_pointer_cast<Interface>(extra);
    	ui->SetScale(float(event.data) / 100.0f);
    	auto window = dynamic_pointer_cast<Window>(event.source);
    	window->SetShape(event.position.x, event.position.y, event.size.x, event.size.y);
    	return true;
    }
    
    int main(int argc, const char* argv[])
    {
    	fstream sourceFile;
    	string contentsOfWebsite = "";
    
    	cout << "app starting..." << endl;
    	auto displays = ListDisplays();
    	displays = ListDisplays();
    
    	auto win = CreateWindow("Slastraf Tool", 0, 0, 1000 /** displays[0]->scale*/, 600 /** displays[0]->scale*/, displays[0], WINDOW_HIDDEN | WINDOW_CENTER | WINDOW_TITLEBAR | WINDOW_RESIZABLE | WINDOW_DOUBLEBUFFERED);
    	win->SetMinSize(600, 300);
    
    	auto ui = CreateInterface(win);
    
    	auto mainpanel = CreatePanel(0, 0, win->ClientSize().x, win->ClientSize().y, ui);
    	mainpanel->SetAlignment(1, 1, 1, 1);
    
    	auto mainmenu = CreateMenu("", mainpanel);
    	int menuheight = mainmenu->GetSize().y;
    
    	auto menu_file = CreateMenu("File", mainmenu);
    
    
    	auto menu_new = CreateMenu("New", menu_file);
    	auto newFileWindow = CreateWindow("Create New File", 0, 0, 420, 2 * 69, displays[0], WINDOW_HIDDEN | WINDOW_CENTER | WINDOW_TITLEBAR | WINDOW_RESIZABLE | WINDOW_DOUBLEBUFFERED);
    
    	auto newFileUi = CreateInterface(newFileWindow);
    	auto mainNewFilepanel = CreatePanel(0, 0, newFileWindow->ClientSize().x, newFileWindow->ClientSize().y, newFileUi);
    	mainNewFilepanel->SetAlignment(1, 1, 1, 1);
    	auto mainNewMenu = CreateMenu("", mainNewFilepanel);
    
    	auto textfieldNew = CreateTextField(12, 10, newFileWindow->ClientSize().x*0.5, 32, mainNewMenu);
    	textfieldNew->SetAlignment(1, 1, 1, 0);
    	textfieldNew->SetText("untitled");
    	auto menu_saveTextNewFile = CreateButton("Save and close (doesnt work yet, just hide the window)", 12+(newFileWindow->ClientSize().x*0.5), 10, newFileWindow->ClientSize().x*0.23, 32, mainNewMenu);
    
    
    	auto menu_open = CreateMenu("Open File...", menu_file);
    
    	auto menu_save = CreateMenu("Save...", menu_file);
    
    	auto menu_export = CreateMenu("Export", menu_file);
    
    	ui->SetScale(displays[0]->scale);
    	ListenEvent(EVENT_WINDOWDPICHANGED, win, RescaleUI, ui);
    
    	win->Show();
    	win->Activate();
    
    	shared_ptr<TreeViewNode> dragnode, destnode;
    
    	while (true)
    	{
    
    		auto event = WaitEvent();
    
    		switch (event.id)
    		{
    		case EVENT_WIDGETDROP:
    			dragnode = event.source->As<TreeViewNode>();
    			if (dragnode)
    			{
    				destnode = event.extra->As<TreeViewNode>();
    				dragnode->Insert(destnode, event.data);
    			}
    			break;
    
    		case EVENT_WIDGETSELECT:
    			break;
    		case EVENT_WIDGETACTION:
    
    			if (event.source == menu_open)
    			{
    				wstring file = RequestFile(L"Open File");
    				sourceFile.open(file, ios::out);
    				if (!sourceFile) {
    					sourceFile.close();
    				}
    				else {
    					Notify("Opened file. Please export it later as .html to open it in browser.");
    				}
    				break;
    			}
    
    			if (event.source = menu_new) {
    
    				newFileUi->SetScale(displays[0]->scale);
    				ListenEvent(EVENT_WINDOWDPICHANGED, newFileWindow, RescaleUI, newFileUi);
    				newFileWindow->Show();
    				newFileWindow->Activate();
    				break;
    			}
    
    			if (event.source == menu_save) {
    				string errors = compileAndWrite(sourceFile, contentsOfWebsite);
    				if (errors != "") {
    					Notify(errors);
    				}
    				sourceFile.close();
    				break;
    			}
    
    			if (event.source == menu_saveTextNewFile) {
    				sourceFile.open(textfieldNew->text, ios::out);
    				newFileWindow->Close();
    				newFileWindow->Hide();
    
    				newFileWindow = nullptr;
    				break;
    			}
    
    			if (event.source == menu_export) {
    				string errors = compileAndExport(contentsOfWebsite);
    				break;
    			}
    
    			break;
    		case EVENT_WINDOWCLOSE:
    			return 0;
    			break;
    		}
    	}
    	return 0;
    }
    
    //writes all changes to the file, does not export it
    string compileAndWrite(fstream& file, string& contentsOfWebsite)
    {	
    	/*
    	if (contentsOfWebsite == "") {
    		return "The app is empty, most likely an error.";
    	}
    	*/
    	file << "hello thois isa a test";
    	return "";
    }
    
    string compileAndExport(string& contents) {
    	return "";
    }

    I create a button at line 53 which is on a second window.
    This window is shown in line 107, so far so good but at line 124 it will not hide.

    I hope you can fix this issue soon. 

    Regards
    Slastraf

  9. Happy to be a part of this.

    As you said, lack of proper communication contributed pretty badly for the state of the project. Text communication is probably the worst of all forms. Voice would be good but the best would be in-person, though its impossible .
    Hereby I propose that we could meet on a voice channel maybe discord some time soon.
    Lets make more discussion about game design and make a better plan about everything (e.g. code documentation, asset list, map design etc.). 

  10. 4 hours ago, hom.png said:

    I don't think this is the right thing because I want it to rotate towards the mouse yet this will rotate it constantly however, there is some good use in this as if I make a rotVec for the y coordinates as well and do the whole Rot=ATan(rotVecy/rotVecx) thing and then do self.entity:SetRotation(0,self.entity:GetRotation().y+(Rot*lookSpeedMultiplier),0) and then run the code you can see that the moment you cross where x=0 the entity starts rotating the other way and I assume this is the base of the issue.

    you would need to put the mouse back, maybe use Math Lerp function for that.

  11. So you are only setting the y rotation of lets say your character controller.
    Why would you not just rotate it based on direction vector and make it really small ?

    local rotVec = window:GetMousePosition()x-(window:GetWidth*0.5)

    local lookSpeedMultiplier = 0.01

    self.entity:GetRotation(0, self.entity.rotation.y + (rotVec * lookSpeedMultiplier), 0)

     

    I just wrote the code in here so there might be errors but it may work. Also always make *0.5 instead of /2 because the compiler could not detect that /2 is more difficult to calculate than *0.5

×
×
  • Create New...