change between menu or pause screens on libgdx - menu

i´m trying to made a couple screens like a menu or a pause, and in these screens i want to put some "other screens", for example in my menu i want a button options and then the app slides and shows another screen with options like music/volume, or like a castlevania/megaman game when the user pause the game, some options are displayed, change the inventory, buy an hability or something like that, in this case when we try to manage the inventory the screen change an shows the information about the current inventory, so my question is how is managed this on libgdx, because i know there is a screen class but is that the way to do it?, constantly change between screens or there's another way.

This is actually what you need scene2D.
scene2d is well equipped for laying out, drawing, and handling input for game menus, HUD overlays, tools, and other UIs. The scene2d.ui package provides many actors and other utilities specifically for building UIs.
Lets assume you know about Stage which you will need to add your Actors like(buttons,textfield,input) all you have to do is implement Table, part of scene2D that contains method such as setVisible.
Lets say for example this is your log-in HUD. Now you want to hide it when a button is clicked.
Table table = new Table();
table.add(textField);
table.add(logInButton);
stage.addActor(table);
if(hideButton.isChecked())
{
table.setvisible(false)
}
else
{
table.setVisible(true)
}
This will hide all your Actors that contains in your table.

Related

Are InputComponents and Dialogs incompatible?

In the simple Dialog below:
// choice of layout has no impact:
Container cont=new Container(new TextModeLayout(3, 1));
//Container cont=new Container(new BoxLayout(BoxLayout.Y_AXIS));
TextComponent firstName=new TextComponent().label("First Name").text(person.firstname);
TextComponent lastName=new TextComponent().label("Last Name").text(person.lastname);
TextComponent cost=new TextComponent().label("Cost per Session").text(person.getCostString());
cost.getField().setConstraint(TextArea.DECIMAL);
// NOTE HERE
// doesn't work: // works:
cont.add(firstName); // cont.add(firstName.getField());
cont.add(lastName); // cont.add(lastName.getField());
cont.add(cost); // cont.add(cost.getField());
Dialog.show("Edit Client", cont, new Command(CANCEL), new Command(OK));
Nothing appears in the Dialog unless I add the TextField instead of the TextComponent to my container at the NOTE HERE comment. This means I lose the nice appearance of the labelled input fields (yes I know I could label them myself, but they wouldn't look as good on different devices). My choice of layout manager at the top does not affect this issue (I've tried several). I can't find evidence online to conclude there's an incompatibility here, adding TextComponents and other InputComponents works fine on a Form, just not in a Dialog.
I'm having the same problem in another Dialog that uses PickerComponents. The PickerComponent doesn't appear unless I add the Picker itself, and then the Picker spawned from a Dialog looks all wrong. I'm hoping the simpler code question above will answer this quandary as well.
It's worth noting I've made no theme changes and this problem is noted in both the Android and Apple skins as well as on an actual Android phone. Thanks in advance for any help!
You shouldn't do input in a Dialog as it creates a very problematic user experience. If you would like things to look like they are in a dialog you can use styles and layouts to make a Form feel like a Dialog but you shouldn't use a Dialog.
The reason this fails is a bit complicated but here are the high level problems with using a dialog:
Dialogs don't grow implicitly - This is a huge problem for text input as the component needs space to resize with input and even more so for the animated TextComponent which needs to shift things around. The size of a Dialog is determined when it's shown and that's a big problem
This becomes a bigger problem on Android where the screen resizes during input and distorts the dialog completely. It's one of those things you'll only see on the device because it's really hard to simulate the virtual keyboard.
Scrollability is hard in a Dialog and text components need a scrollable parent so you can scroll between the various edit components
Picker component uses a form of Dialog to show input and this can collide with your dialog
Dialogs are hard to get right for suspend/resume behavior. Suspend/resume happens when the app is minimized or sent to the background. E.g. say you have an incoming call while typing in the dialog. When you go back to the app we want to show the last form. If we show the dialog it will block and we won't know which parent form to show anyway. So when an app is suspended dialogs are just disposed in the default code generated in the main class. It makes more sense.

Making and Object uniteractable

So I have a part of my game where the character is selecting an area of the map. And it opening up a panel. I have made it so that happens but an=m now stuck on the other part of it. I want only certain area of the map to be intractable, so that I can bar the player from selecting areas of the map that they aren't ready for. I have no idea how to make game objects in the game uninteractable. I have looked on Stack overflow, Youtube an d the Unity API to no success. Can someone help me with that.
How to make things un-interactable will vary depending on your situation. I'll be presuming that you're map is broken up into a grid of sorts.
The basic setup would involve a bool, probably called 'CanAccessZone'.
Then you'll need a class, to store any access info and popup logic, by popup logic I mean make the element either non-interactable or show a popup, with the shown popup being dependant on 'CanAccessZone'. This class can then be set up by your Map class when the level is loaded, or you could let the popup class grab the necessary values from the Map class.
If you're using Unity's UI buttons for the map pieces, then you could set interactable to false, until you want to let the player access the zone. If you want to display a popup informing the player that they can't access the zone, then your button will be interactable, but the click will delegate to your popup logic method.
It's a similiar principle if you're using gameobjects as buttons. You'd be using any of the OnMouse events to handle click events. https://docs.unity3d.com/ScriptReference/MonoBehaviour.html
Hopefully this'll lead you in the right direction.

Orchard CMS. Add sub items from edit screen

I'm trying to develop my first module in Orchard and stuck with the following problem.
I have Box content type that contain Books. What I want to achieve is to allow user to add books from box edit screen in admin. The process is the following:
User selects a Box in admin and click edit.
In edit screen a list of books is displayed with buttons "Edit", "Delete" and "Add Book"
The user clicks "Add Book" button and add book screen appears.
The user enters required metadata and clicks "Save"
The user is redirected back to Box edit screen with new book added to the list.
I'm looking for advise on what is the best way to implement this.
There are several ways to do that, most of which don't require building a module.
You could use the updated list feature in the new Orchard 1.8. That does pretty much exactly what you describe.
You could use taxonomies, where the boxes are terms (terms have their own content type that you can extend). The workflow is kinda backwards with this, where you put books in boxes rather than picking from the box which books belong.
You could use a content picker field configured for multiple items, and constrained to the book content type.
You could build your own module, with a relationship between your types, as explained here: http://docs.orchardproject.net/Documentation/Creating-1-n-and-n-n-relations but except if this is a pure learning experience, there's little reason to go for that one, as the other three above are so much simpler, and don't require any coding.

Swapping ActionBar items when displaying different Tabs and Detail Views

this is not a technical question, but one for advice regarding the best practices in designing an Android tablet UI.
I've got my concept of an Android Phone app pinned down.
The first activity (master view) launched contains a tab bar with three fragments from which the user can launch detail view activities of different sorts.
Both the master-view activity and the detail-view activities have actions in their action bars. Different detail views have different action items.
My question is: How should I organize and display the action items on a tablet, where an activity combines both views side by side?
The problem is the unified action bar for both the master-view fragment and whatever kind of detail fragment is shown. I do not think it is a good idea to start messing with the contents of the action bar whenever a different kind of detail view is opened.
The Android Design Guide does not tell you much on that front. There is a sample of a Contacts app in the "Multi-pane Layouts" section, but it does not actually deal with the problem. It evades it, by putting the single relevant action as an icon inside the detail view fragment.
Any advice with regards to best practices and references are appreciated.
I would suggest leaving your master details icons in the action bar, whilst putting your details view icons in another view/area within the details fragment.
My reasoning would be that icons in the action bar affect / are associated with the whole app / view on screen. Whilst your details icons only affect the details view and therefor should not be in the action menu when showing multiple fragments.
I guess you will have to see how the designs look..
I am not a fan of the action bar icons being changed from within the same activity (even if it contains multiple fragments), however when you load a new activity (like in your phone design) then I say yeah throw them in the action bar.
If I understand your question correctly, which I think is basically a question of how multiple Fragments (i.e. when on a multi-pane layout such as on a tablet) should contribute to the single ActionBar, it's quite straightforward and it is actually briefly discussed in the documentation here. Essentially, you can have the multiple Fragments all contributing their own menu items / action items to the single action bar, via some simple API calls.

User controls as "screens" in a webpart

I'm workin on my first webpart.
I use some number of user controls as screens. And I have a trouble here.
First screen contains a list of dynamically created options (hyperlinks). After user made a decision with click, I want to change the screen and pass to the new screen some parameters.
My dicision is to load all controls I need on webpart creation. Controls I don't need right now I make invisible.
SomeUserControl1 uc1 = (SomeUserControl1)Page.LoadControl("~/_controltemplates/SomeUserControl1.ascx");
SomeUserControl2 uc2 = (SomeUserControl2)Page.LoadControl("~/_controltemplates/SomeUserControl2.ascx");
uc2.Visible = false;
Controls.Add(uc1);
Controls.Add(uc2);
Option in first user control realized as LinkButtons (serverside). OnClik event calls a special method in the webpart class and in this method i change a visibility of my user controls and pass some parameters to usercontrol2.
I don't like this approach. Are there different ways to realize described functionality?
Thanks!
You need use a ASP.NET Wizard Control, it does what you exactly you want.
From a design standpoint what you are doing looks a little bit frightening. You should think about nesting the various user controls into a single user control that you can use as the face of your webpart. Keep the coupling between the various user controls loose and think about implementing the Observer pattern if you need to do things like playing with control visibility.

Resources