override public void render_main( string text_author, string text, List <Button_s> btnsActions, string btnStyle) { RegisteredChar_s charinfo; //stylebox = GUIStyle("box") //stylebox.border = 0 //GUI.Box(Rect(0, 0, Screen.width / 7, Screen.height / 1), ""); this.ren_start(); // --------- calculate actual author ------------ var char0 = text_author.Split('/')[0]; if (this.controller.registeredChars.ContainsKey(char0)) { charinfo = this.controller.registeredChars[char0]; } else { charinfo = new RegisteredChar_s("ffffff", char0); } // --------- render --------------- var fullw = (int)(this.wwidth * this.contentWidthProp); //GUILayout.BeginVertical("box1", GUILayout.Width(fullw), GUILayout.Height(self.wheight)) //GUILayout.BeginVertical("box1", GUILayout.Width(fullw), GUILayout.Height(self.wheight)) GUILayout.BeginVertical(GUILayout.Width(fullw), GUILayout.Height(this.wheight)); GUILayout.Space(12); // ---- preparing styles ---------- var style = new GUIStyle("label"); style.richText = true; style.fontSize = this.labelFontSize; style.wordWrap = true; var customButton = new GUIStyle("button"); customButton.fontSize = this.buttonFontSize; // ----------- render --------- /* * if (btnStyle is List<string>) * { * // -------- custom render ----------- * // tuple is specific action * if (btnStyle[0] == "function") * { * try * { * btnStyle[1](this.controller, new Dictionary<object, object> { * { * "fwidth", * fullw}, * { * "btnheight", * this.buttonHeight}, * { * "btnstyle", * customButton}, * { * "labelstyle", * style}}); * } * catch (Exception e) * { * Console.WriteLine("Error in call custom GUI buttons: " + e.ToString()); * } * } * } else { */ // --------- normal render ---------- //GUILayout.BeginHorizontal() if (charinfo.showname != "") { GUILayout.Label(String.Format("<color=#%sff><b>%s</b></color>", charinfo.color, charinfo.showname), style, GUILayout.Width(fullw)); GUILayout.Space(2); } /* * // -- special processing for translation -- * if (this.controller.engineOptions["usetranslator"] == "1" && this.controller.engineOptions["translatetexts"] == "1") * { * GUILayout.Label(translateText(text), style, GUILayout.Width(fullw)); * } */ GUILayout.Label(text, style, GUILayout.Width(fullw)); GUILayout.FlexibleSpace(); // ---- show buttons --- if (!this.controller.isHideGameButtons) { if (btnStyle == "compact") { GUILayout.BeginHorizontal(); } foreach (var i in Enumerable.Range(0, btnsActions.Count)) { // preparing button texts var restext = btnsActions[i].label; /* * if (this.controller.engineOptions["usetranslator"] == "1" && this.controller.engineOptions["translatebuttons"] == "1") * { * restext = translateText(restext); * } */ var fintext = restext; if (this.controller.GetConfigEntry("Skins", "usekeysforbuttons")) { if (this.controller.arKeyKodes.Length > i) { fintext = this.controller.arKeyKodes[i].ToUpper() + ": " + fintext; } } // render button if (btnStyle == "normal") { if (btnsActions.Count > 1) { if (GUILayout.Button(fintext, customButton, GUILayout.Width(fullw), GUILayout.Height(this.buttonHeight))) { this.controller.call_game_func(btnsActions[i]); } } else { // special case for 1 button GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); customButton.fontSize = (int)(customButton.fontSize * 1.2); if (GUILayout.Button(fintext, customButton, GUILayout.Width(fullw * 0.25f), GUILayout.Height(this.buttonHeight * 1.5f))) { this.controller.call_game_func(btnsActions[i]); } GUILayout.EndHorizontal(); } } if (btnStyle == "compact") { if (GUILayout.Button(fintext, customButton, GUILayout.Width(fullw / 2 - 2), GUILayout.Height(this.buttonHeight))) { this.controller.call_game_func(btnsActions[i]); } if (i % 2 == 1) { GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); // pass } } } if (btnStyle == "compact") { GUILayout.EndHorizontal(); } } GUILayout.Space(16); GUILayout.EndVertical(); this.ren_end(); }
override public void render_main( string text_author, string text, List <Button_s> btnsActions, string btnStyle) { RegisteredChar_s charinfo; // --------- calculate actual author ------------ var char0 = text_author.Split('/')[0]; if (this.controller.registeredChars.ContainsKey(char0)) { charinfo = this.controller.registeredChars[char0]; } else { charinfo = new RegisteredChar_s("ffffff", char0); } // --------- render --------------- var fullw = this.wwidth - 30; GUILayout.BeginVertical(GUILayout.Width(fullw)); var style = new GUIStyle("label"); style.richText = true; style.fontSize = this.labelFontSize; style.wordWrap = true; var customButton = new GUIStyle("button"); customButton.fontSize = this.buttonFontSize; if (charinfo.showname != "") { GUILayout.Label(String.Format("<color=#%sff><b>%s</b></color>", charinfo.color, charinfo.showname), style, GUILayout.Width(fullw)); } /* * if (this.controller.engineOptions["usetranslator"] == "1" && this.controller.engineOptions["translatetexts"] == "1") * { * GUILayout.Label(translateText(text), style, GUILayout.Width(fullw)); * } */ GUILayout.Label(text, style, GUILayout.Width(fullw)); GUILayout.FlexibleSpace(); /* * if (btnStyle is string[]) * { * // tuple is specific action * if (btnStyle[0] == "function") * { * try * { * btnStyle[1](this.controller, new Dictionary<object, object> { * { * "fwidth", * fullw}, * { * "btnheight", * this.buttonHeight}, * { * "btnstyle", * customButton}, * { * "labelstyle", * style}}); * } * catch (Exception e) * { * Console.WriteLine("Error in call custom GUI buttons: " + e.ToString()); * } * } * }*/ if (!this.controller.isHideGameButtons) { if (btnStyle == "compact") { GUILayout.BeginHorizontal(); } foreach (var i in Enumerable.Range(0, btnsActions.Count)) { var restext = btnsActions[i].label; /* * if (this.controller.engineOptions["usetranslator"] == "1" && this.controller.engineOptions["translatebuttons"] == "1") * { * restext = translateText(restext); * } */ var fintext = restext; if (this.controller.GetConfigEntry("Skins", "usekeysforbuttons")) { if (this.controller.arKeyKodes.Length > i) { fintext = this.controller.arKeyKodes[i].ToUpper() + ": " + fintext; } } if (btnStyle == "normal") { if (GUILayout.Button(fintext, customButton, GUILayout.Width(fullw), GUILayout.Height(this.buttonHeight))) { this.controller.call_game_func(btnsActions[i]); } } if (btnStyle == "compact") { if (GUILayout.Button(fintext, customButton, GUILayout.Width(fullw / 2 - 2), GUILayout.Height(this.buttonHeight))) { this.controller.call_game_func(btnsActions[i]); } if (i % 2 == 1) { GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); // pass } } } if (btnStyle == "compact") { GUILayout.EndHorizontal(); } } GUILayout.EndVertical(); GUI.DragWindow(); }