Scolring - Forum

Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology

Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered

You are not logged in.

#1 13-Oct-2014 18:37:56

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,543
Website

Setting plugit link options

colleagues:

with the text input/output plugit I wrote (in another thread, but since this is a new question others might find useful, here it is), the editor allows for the creation of one of three fonts: arial, lucida console, and system.
the plugit has an action called "Print Incoming Message". when that action is triggered, the plugit executes cbprintmessage.

let's say I have the dialog box plugit in the scene, and when the user triggers the "Yes/No" event, I want the text input/output plugit to display lucida console font when the plugit executes the "Print Incoming Message" action. 

how would I alter my client, editor, an xml files to allow this? I checked the dialogbox plugit, but still don't understand how it configures the link window and options

answer at your leisure, it's a holiday here inthe u.s.

.xml file:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<PLUGIN name="chatwindow" version="1.0" type="misc">

  <DESCRIPTION>Chat Window Plugit</DESCRIPTION>

  <HELP>Template plugIT help</HELP>

  <EDITOR>

    <SCRIPT path="./echatwindow.pkg" />

    <PARAM name="width" type="value" />
    <PARAM name="height" type="value" />
    <PARAM name="window_name" type="value" />    
    <PARAM name="window_background_color_value" type="value" />
    <PARAM name="font_color" type="value" />
    <PARAM name="font_color" type="value" />
    <PARAM name="font_type" type="value" />
    <PARAM name="font_size" type="value" />

  </EDITOR>

  <CLIENT minstance="true">

    <SCRIPT path="./cchatwindow.pkg" />

    <ACTION name="Print Incoming Message">
    </ACTION>

    <EVENT name="Send Outgoing Message">
    </EVENT>

  </CLIENT>

</PLUGIN>

editor file

// prototype of the cbCloseEdit function in case you don't use params

//proto cbCloseEdit = fun [] [[S S] r1];;

//proto cbCloseEdit = fun [u0] [[S S] r1];;

// Close callback called on apply / Ok button, this callback return the parameters to save in the XOS project

fun cbCloseEdit(editorinterface)= 
  let editorinterface-> [ctrlwinw ctrlwinh window_background_color_button font_color_button window_name_textline fontpicker font_size_control] in
  //get width value set in editor
  let ftoi getEdCtrlFloatValue ctrlwinw -> width in
  let ftoi getEdCtrlFloatValue ctrlwinh -> height in
  let ftoi getEdCtrlFloatValue font_size_control -> fontsize in
  //change width value from integer to string and save in xos file
  ["width" itoa width]::
  ["height" itoa height]::
  //["window_background_color_value" (itoh getEdCtrlColorButtonColor window_background_color_button)]::
  ["window_background_color_value" (itoh getEdCtrlColorButtonColor window_background_color_button)]::
  ["font_color" (itoh getEdCtrlColorButtonColor font_color_button)]::
  ["window_name" (getEdCtrlTextLineValue window_name_textline)]::
  ["font_type" (getSelectedEdCtrlSelect fontpicker)]::
  ["font_size" itoa fontsize]::
  nil;;





// Destroy callback called when the editor window is destroyed, this is useful to destroy added objects or resources

fun cbDestroyEdit()=

  0;;





// Init function called when a user the plugIT Editor

fun dynamicedit(winstr, inst, viewstr) =
  //get width value from .xos file

  let atof (getPluginInstanceParam inst "width") -> width in
  //if width not set, set it to 800
  let if width == nil then 800.0 else width -> width in 
  //get window_ background_color
  let htoi   (getPluginInstanceParam inst "window_background_color_value") -> window_background_color in
  let if window_background_color == nil then 0x000000 else window_background_color-> window_background_color in

  //get window height
  let atof (getPluginInstanceParam inst "height") -> height in
  //if width not set, set it to 800
  let if height == nil then 400.0 else height -> height in 
  let if height <. 150.0 then 150.0 else height -> height in 
  // size of the window
  let [400 320] -> [iw ih] in
  let 10 -> ypos in
  //create window width label
  let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 120 20 "Window width" nil -> labelwinw in

  //create window width float control
  let crEdCtrlFloat winstr 130 ypos 100 20 width 0.0 12000.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlwinw in
  //create window height label
  let crEdCtrlLabel winstr 10 (set ypos = ypos + 35) + 2 120 20 "Window Height" nil -> labelwinh in
 //create window height float control
  let crEdCtrlFloat winstr 130 ypos 100 20 width 0.0 12000.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlwinh in 
 //create background color control  labbel
 let crEdCtrlLabel winstr 10 (set ypos = ypos + 55) + 2 160 20 "Window Background Color" nil -> window_background_color_label in
 //create background color control
 let crEdCtrlColorButton winstr 180 ypos 165 20 window_background_color 0 EDWIN_RESIZE_MW nil -> window_background_color_button in
 //create font color conrol label
 let crEdCtrlLabel winstr 10 (set ypos = ypos + 45) + 2 160 20 "Font Color" nil -> font_color_label in
 //change hex string of font color into hex interger from .xos file
 let htoi   (getPluginInstanceParam inst "font_color") -> font_color in
 //if ther is no font color, set it to white..see http://www.nthelp.com/colorcodes.htm
 let if font_color == nil then 0xFFFFFF else font_color-> font_color in
 //create font color control
 let crEdCtrlColorButton winstr 180 ypos 165 20 font_color 0 EDWIN_RESIZE_MW nil -> font_color_button in
 //create window name label
 let crEdCtrlLabel winstr 10 (set ypos = ypos + 45) + 2 160 20 "Window Name Label" nil -> window_name_label in
 //create window name text area (in scol it's a textline)
 //get window name
 let  (getPluginInstanceParam inst "window_name") -> window_name in
 //get font type
 let (getPluginInstanceParam inst "font_type") -> font_type in
 let atof (getPluginInstanceParam inst "font_size") -> fontsize in
 let if fontsize == nil then 12.0 else fontsize -> fontsize in
 let crEdCtrlTextLine winstr 180 ypos 200 20 window_name nil EDWIN_RESIZE_MW -> window_name_textline in
 let crEdCtrlLabel winstr 10 (set ypos = ypos + 45) 160 20 "Type of Font" nil -> font_labeltype in
 let crEdCtrlSelect winstr 180 ypos 200 120 EDWIN_RESIZE_MW -> fontpicker in
  let crEdCtrlLabel winstr 10 (set ypos = ypos + 45) + 2 160 20 "Font Size" nil -> font_size_label in
  //create font size control
  let crEdCtrlFloat winstr 180 ypos 160 20 fontsize 0.0 100.0 1.0 0 nil EDWIN_RESIZE_MW -> font_size_control in
  (
  
    // resize the editor window
    setEdWindowSize winstr iw ih; 
    fillEdCtrlSelect fontpicker "System"::"Arial"::"Lucida Console"::nil;
    selectEdCtrlSelect fontpicker font_type;
    
    [mkfun1 @cbCloseEdit [ctrlwinw ctrlwinh window_background_color_button font_color_button window_name_textline fontpicker font_size_control]  @cbDestroyEdit];
  );;

client file

//struct definition
  struct Chatwindow = [
  CHATwindow_plugin_instance           				: PInstance,
  CHATwindow_window_object_container					: ObjContainer,  
  CHATwindow_parent_chat_window							: ObjWin,
  CHATwindow_chat_font										: ObjFont,
  CHATwindow_ongoing_chat_textfield						: CompText,
  CHATwindow_chat_entry_textfield						: CompText
  				
  ]mkChatwindow;;
  
 fun printmessage(constr, value)=
	_ADDcompText constr.CHATwindow_ongoing_chat_textfield strcatn value:: "":: "\n"::nil constr.CHATwindow_chat_font [0x00FFFF 0 0 0xFFFF00] CT_END;
	_PAINTcontainer constr.CHATwindow_window_object_container;
 0;;
 
 fun cbprintmessage(inst, from, action, param, reply, constr)=
 	printmessage constr param;
 	0;;
 

fun cbDestroy(inst, from, action, param, reply, constr)=
	_DScompText constr.CHATwindow_ongoing_chat_textfield;
	_DScompText constr.CHATwindow_chat_entry_textfield;
	_DSfont constr.CHATwindow_chat_font;
	_DScontainer constr.CHATwindow_window_object_container;
	_DSwindow constr.CHATwindow_parent_chat_window;

0;;

fun deleteOb(inst, constr)=
	_hideconsole; 

  cbDestroy inst nil nil nil nil constr;

  0;;

//add text to ongoing_chat_textfield here
fun addtext(textobject, user_parameter,type,value)=
	//update contents of chat interface
	let ""-> empty_text_value in
		(
			_ADDcompText user_parameter.CHATwindow_ongoing_chat_textfield strcatn value:: "":: "\n"::nil user_parameter.CHATwindow_chat_font [0x00FFFF 0 0 0xFFFF00] CT_END;
			_PAINTcontainer user_parameter.CHATwindow_window_object_container;
  			_SETcompText textobject "" user_parameter.CHATwindow_chat_font [0x00FFFF 0 0 0xFFFF00] CT_BEGIN; 

			_PAINTcontainer user_parameter.CHATwindow_window_object_container;
			 _DMSevent this (getPluginInstanceEvent user_parameter.CHATwindow_plugin_instance "Send Outgoing Message") value nil;
			0;
		);
0;;
///create plugit function
fun newOb(inst)=
   //get width value from .xos file
   let atoi (getPluginInstanceParam inst "width") -> width in
   let htoi  (getPluginInstanceParam inst "window_background_color_value") -> window_background_color in
   //get height value from .xos file
   let atoi (getPluginInstanceParam inst "height") -> height in
      let atoi (getPluginInstanceParam inst "font_size") -> fontsize in
   //get window name from .xos file, if nil set to unnamed window
   let getPluginInstanceParam inst "window_name" -> window_name_value in
   let getPluginInstanceParam inst "font_type" -> font_type in
   let if window_name_value == nil then "Unnamed Window" else window_name_value -> window_name_value in
	let _CRwindow _channel DMSwin 0 0 width height WN_TOPMOST|WN_NOSCOL window_name_value  -> thisparentchatwindow in
	let _CRcontainerFromObjWin _channel thisparentchatwindow 0 0 width height CO_CHILDINSIDE window_background_color "hackerwindow" -> thiscontainer in
	let _CRfont _channel fontsize 0 0 font_type-> thisfont in
	let htoi   (getPluginInstanceParam inst "font_color") -> font_color in

   let if font_color == nil then 0xFFFFFF else font_color-> font_color in
	let  _CRcompText _channel thiscontainer  nil [0 (height-50)] OBJ_ENABLE|OBJ_VISIBLE|CT_LEFT|CT_WORDWRAP|CT_EDITLINE 0 width 50  "text entry field" 		thisfont [font_color 0 0 font_color] [0xFFFFFF 50] nil nil   -> thistextentryfield in
	let _CRcompText _channel thiscontainer nil [0 0] OBJ_ENABLE|OBJ_VISIBLE|CT_LEFT|CT_LABEL|CT_WORDWRAP|CT_LABEL|CT_SELECT OBJ_CONTAINER_KEYDOWN width (set height= height-50)  strcat "ongoing chat text here"  "\n" thisfont [font_color 0 0 font_color] [0xFFFFFF 50] nil nil-> thisongoingchatfield in
	
	let mkChatwindow [inst thiscontainer thisparentchatwindow thisfont thisongoingchatfield thistextentryfield]->constr in
		(

			_CBcompTextValidation constr.CHATwindow_chat_entry_textfield @addtext constr  CT_VALIDENTER;
			_PAINTcontainer constr.CHATwindow_window_object_container;
			PluginRegisterAction inst "Print Incoming Message" mkfun6 @cbprintmessage constr;
			//PluginRegisterAction inst "Destroy" mkfun6 @cbDestroy constr;

			setPluginInstanceCbDel inst mkfun2 @deleteOb constr;

		);
0;;



fun IniPlug(file)=

  PlugRegister @newOb nil;

  setPluginEditor @dynamicedit;

  0;;
  
  
  

Offline

#2 13-Oct-2014 23:18:39

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,162
Website

Re: Setting plugit link options

hmm didn't understood the question ^^

Online

#3 14-Oct-2014 02:17:40

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,543
Website

Re: Setting plugit link options

arkeon wrote:

hmm didn't understood the question ^^



2 dialog box plugits linked to 1 text input/output plugiit.

dialog box 1 ok event makes the "Print Incoming Message" print a message to a comptext box in lucida console
dialog box 2 ok event makes the "Print Incoming Message" print a message to a comptext box in arial

what i'm wondering is how to enable a plugit action's attributes, to some extent, be determined by other plugits. right now, the plugit only prints in the font set by the editor, not set by a particular link.

Offline

#4 14-Oct-2014 19:10:50

arkeon
Admin. / Scol language & OpenSpace3D developer
From: Nantes
Registered: 30-Mar-2009
Posts: 5,162
Website

Re: Setting plugit link options

ha ok
you can add an action set font and then in the plugit manage the change the current font ?!

Online

Board footer

Powered by FluxBB