Best way to implement a dialogue system in Game Maker Studio 2 - game-development

I am trying to implement a dialogue system for a game that I am making. I have the actual system for handling the text and input all set up. My question is asking about how you actually show the text and have it formatted properly in a certain sprite.

The "best way" is a broad and subjective term, and it may be different for each person, but I can give you some tips regarding the question in your second sentence, to put you in the right direction:
How to actually show the text and have it formatted properly in a certain sprite?
Considering a dialogue box is a User Interface, you should put the code, that draws the dialog box, in the Draw_Gui of the object. Because that will draw stuff in front of the camera, and doesn't need to keep positions of the map in mind. Since Draw_Gui is in an object, you can put the dialogue box in a parent NPC, or let a seperate persistent object handle it (called an object manager)
To format it properly within a sprite, you can use draw_text_ext(x,y,string,sep,w), especially the w parameter will be helpful, as that allows you to let the text start on a new line if it exceeds past that width, and the sep parameter let you deside the space between the lines of text, to ensure the amount or lines in your dialog box will look clean.

Related

Programmatic access to Visio shape tooltip

To avoid an XY problem, here's what I'm trying to accomplish: when a shape is selected, I want detail text about that shape to appear on the screen.
I first tried using Shape Data, but it supports only single-line name=value pairs. My detail information is an arbitrary, multiline text blob.
My next thought was to used the shape's ScreenTip (aka tooltip) to hold the text data, then write some VBA code to handle the _SelectionChanged event. When a shape is selected I want to copy it's ScreenTip text into the text of another object (my details panel).
I got the _SelectionChange event-handling working, but poking around the Selection object in the debugger I can't find any property of the selected object that exposes the ScreenTip information.
Is Visio's programming API too anemic to support his kind of thing? Is there another way I might be able to do this? Is there another tool that might be better for this (preferably free)?
Visio's API is capable of doing this, handily.
It seems you're not aware of Visio's shapesheet, which is where the screen tip text is stored, along with pretty much anything you'd want to know about a shape.
To access the screen tip text you simply read the Comment cell from the selected shape's shapesheet:
Application.Selection(1).CellsU("Comment").ResultStr(visNone)
This code will return the comment text.
You're on the right track using the SelectionChange event, though of course you're checking that the selection count = 1, or at least >0.

java3d Picking objects

I am building a java3d GUI, using which users can create custom scene graphs, without needing to know the code, i want to pick specific boxes using mouse, and i want to be able to move them around.. so for that i need picking..
There are say, 2 boxes and 2 spheres in my scenegraph. I just want to pick one of them and know which one was picked. I can find out what type of object was clicked, like if i click on specific sphere, or box, i can find that out, but i dont know how can i find out which object was it, so i can process it.
Could anyone suggest me a solution to the problem? All I want is to know
which object was picked. That's all.
Ok, for now the problem has been solved.
Whenever u add a box or a sphere into scene graph, you need to add custom userData to these object.
e.g. if u are adding a Box object, then
boxOb.setUserData("box1"); //this can be any datatype
when you retrieve data from picking, you just call getUserData() method on getNode() method.
BAMM!! you will get the custom datatype which u set, you can process this further as per your application.
Cheers :)

Creating oscilloscope controls with LabVIEW

I am creating simple application in NI LabVIEW - Lissajous Curves from signal generated by NI Elvis.
I have already added Osciloscope control and connected it to the XYGRaph. But I would also like to have some values that could be changed. I would like to have options to set values like in this image:
How can I Add them to my project?
Thanks in advance
The two highlighted controls look like 'Dial' controls which can be found on the 'Numeric' palette on the 'Modern' control palette (also in 'Classic' and 'Silver' depending on you LabVIEW version).
Looking at the Vertical Position control this has the numeric indicator visible which can be show by right clicking on the dial, and from the menu move across 'Visible Items' and select 'Digital Display'.
The Scale Volts dial looks to have some kind of drop down menu which I guess would have pre-set values. You could use an enumerated data type for this and code you user interface event structure to sync these two. Your user interface event structure could also update the properties of the graph (use a Property Node from the 'Application Control' Pallet of the 'Programming' section of the Block Diagram 'Functions Pallet') to change the displayed range (Scale Volts).
Have you looked at the example code from the image block diagram?
The two highlighted boxes are known as Knob controls. There are a variety of controls for changing values in LabView.
Please see the below figure to understand what I am trying to explain.
This is how you get the knob controls:
http://i.stack.imgur.com/sICHw.png
How to assign the values to the min and max of the control can be changed from the knobs property. Right click -> property. see below
http://i.stack.imgur.com/wxfsC.png
If you have any further questions, don't fail to read up the help from Labview. Its quite useful and very demonstrative.

QInputDialog like thing in Cocoa/Xcode?

I'm fairly new to Xcode and Cocoa/Objective-C and I'm trying to implement something as simple as a QInputDialog that can be re-used throughout the program - with a unique message to the user each time it is launched and return a string as a result.
I have searched the web and found multiple methods but nothing seems to be quite clear or concise - well enough for me to understand anyway.
Is there anything out there as simple as:
Create/Launch a window from a method with a new message label to the user in the form of a string.
Has an NSTextField to receive the users input.
Close the window and return the string from the text field (if accepted) to the calling method.
??
Modal prompts for input are very un-Mac-like. It's like smashing the user's face in with a cricket bat and yelling “TELL ME THE ANSWER NOW!”
The correct solution is to put your text field into a non-modal window, so that the value is already ready when the user invokes whatever action needs the value. Beep and show the “hey, you forgot this” icon if the user hasn't filled in the field and you need a value there. If the field is not relevant in the window the user starts the action from, or if you're going to need several facts as input, then show another window, non-modally, with its own window controller, to take in all the input you'll need for the action.
A separate, non-modal window will also enable the user to fill out and/or perform multiple such actions in parallel.
If you must demand the value with a modal dialog, you can and should make it a sheet, but you'll still need to build the panel and its contents from scratch in IB or code.
See also the Sheet Programming Guide and the chapter on windows in the Human Interface Guidelines.

Connecting two DialogBoxes in GWT

In my GWT project, I'm trying to get it so two DialogBoxes can pass information between each other. One of them holds a MapWidget, and when a button is pressed in the other DialogBox, the position information is received from that other DialogBox's MapWidget. Does anyone have any tips for how I should coordinate between having two different DialogBoxes show up? Should I wrap the code for the two in a Composite? Furthermore, is there an example anywhere of dealing with two DialogBoxes at once in GWT? For example, if I click outside of the two boxes, both should be dismissed. I'm wondering if there's a way to keep both of them in focus at once, so I can switch between the two without causing either to disappear.
Sharing Data Between Dialog Boxes
In my opinion, the "correct" way to do this would be to implement some sort of MVP structure in the application so that a presenter manages the view (DialogBoxes, among other things) and knows how to pass simple data to the view for it to display (the presenter would handle the MapWidget data, the view would take care of displaying it on the DOM).
However, if you're looking for a quicker/more simpler approach, you have a couple of options (which you choose really depends on the application structure):
Create a Composite, as you mentioned, that knows how to pass the necessary data back and forth. By having the Composite manage the data object and tell the two DialogBoxes how to display it, you are actually approaching an MVP architecture within your Composite.
Subclass DialogBox into a class that contains a HandlerManager (sometimes used as an "Event Bus") that fires events when the button is pressed. You can create events that are designed to pass data back and forth between the two DialogBoxes (even make them type-safe with type parameters). See this StackOverflow question for details on using a HandlerManager. The MVP article, linked above, also has some good information on using an event bus.
Model-View-Presenter is a tried-and-true method of structuring an application that results in more testable code, better project structure, and can help guide you when making decisions like this. I strongly recommend checking it out if you haven't already.
Sharing Auto-Hide Functionality
GWT's PopupPanel (on which DialogBox is based) offers a method addAutoHidePartner(Element) which is describe thusly:
Mouse events that occur within an autoHide partner will not hide a panel set to autoHide.
So, you can create two auto-hiding DialogBoxes that only close when you click outside both of them (e.g., they do not close when you click within either of the boxes) with the following code:
// Create the dialog boxes
DialogBox dbox1 = new DialogBox(true, false);
DialogBox dbox2 = new DialogBox(true, false);
// Set some visual options
dbox1.setPopupPosition(10, 10);
dbox2.setPopupPosition(200, 10);
dbox1.setAnimationEnabled(true);
dbox2.setAnimationEnabled(false);
// Set the dialog boxes' caption and content
dbox1.setHTML("Dialog Box 1");
dbox2.setHTML("Dialog Box 2");
dbox1.setWidget(new HTML("This is the first dialog box."));
dbox2.setWidget(new HTML("This is the second dialog box."));
// Making dobx2 a partner of dbox1 means clicking
// in dbox2 won't cause dbox1 to close
dbox1.addAutoHidePartner(dbox2.getElement());
// Similarly, setting dbox1 as a partner of dbox2 means
// clicking in dbox1 won't cause dbox2 to close
dbox2.addAutoHidePartner(dbox1.getElement());
// Show the dialog boxes
dbox1.show();
dbox2.show();
You can interact with either of the dialog boxes without the other closing. Omit the appropriate call to setAutoHidePartner if you only want a one-way partnership.