Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Selection List / Listbox for any platform

Author
Message
Pentalon
6
Years of Service
User Offline
Joined: 6th Feb 2018
Location:
Posted: 16th Feb 2018 16:22
Hello

I am searching for a way to select from a large list (50 to 100 entrys).
A selection list (listbox) to select multiple entries.
Is there some code arround, that can help or solve my problem ?

Best Regards...
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 16th Feb 2018 17:50 Edited at: 16th Feb 2018 17:51
little example with text/labels.
unfortunately this text have auto width, means you can only click in text.
you can scroll this list with set new position for all or use SetViewOffset y

AGK (Steam) V2017.12.12 : Windows 10 Pro 64 Bit : AMD (17.12.1) Radeon R7 265 : Mac mini OS High Sierra (10.13)
Pentalon
6
Years of Service
User Offline
Joined: 6th Feb 2018
Location:
Posted: 17th Feb 2018 12:28
Hey Super
So schaut das sehr vielversprechend aus.
EInzig, das mit dem Scrollen hab ich nicht kapiert.
Liegt aber wohl daran, dass ich gerade meine ersten Gehversuche mit AppGameKit mache

Danke...
Pentalon
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 17th Feb 2018 16:30 Edited at: 17th Feb 2018 17:18
Quote: "EInzig, das mit dem Scrollen hab ich nicht kapiert."

Du kannst entweder die einzelnen Elemente verschieben oder quasi alles was du siehst.
SetViewOffset ist wie eine Lupe die du drüber bewegen kannst. Was sich nicht mit bewegen soll kann man mit Fix...ToScreen fest nageln.
Die Position würde man als Schieberegler darstellen. Könntest auch zwei Knöpfe für hoch runter machen. Sprites eignen sich auch als Knöpfe. = GetSpriteHitTest ( iSpriteIndex, x, y )
AGK (Steam) V2017.12.12 : Windows 10 Pro 64 Bit : AMD (17.12.1) Radeon R7 265 : Mac mini OS High Sierra (10.13)
Pentalon
6
Years of Service
User Offline
Joined: 6th Feb 2018
Location:
Posted: 18th Feb 2018 11:41
Danke.
Ich habe das Tutorial zu diesem Befehl angeschaut, aber das funktioniert nicht (oder ich mache etwas falsch).
Der Hintergrund, bzw das Bild wird nicht dargestellt.


//background infinite scrolling - good for jetpack joyride style of gameplay

//made for iphone resolution - change for your own prefered
SetVirtualResolution(960,640)

//background array
dim BG[2]

//load background image - change to your own background image
LoadImage (1, "bg.jpg")

//set background sprite
BG[0] = CreateSprite (1)
BG[1] = CloneSprite (BG[0])

//main loop
Do
//get the region offsetting
If Mod (GetViewOffsetX (), GetSpriteWidth (BG[0])) = 0
stage = GetViewOffsetX ()/GetSpriteWidth (BG[0])
SetSpritePosition (BG[0], GetSpriteWidth (BG[0])*stage, 0)
SetSpritePosition (BG[1], GetSpriteX (BG[0]) + GetSpriteWidth (BG[0]), 0)
Endif

//print an information which region you are at
Print (stage)

//offsetting
SetViewOffset (x, 0)
x = x+ 8
Loop
[/Code]

Grüsse,
Pentalon
Pentalon
6
Years of Service
User Offline
Joined: 6th Feb 2018
Location:
Posted: 18th Feb 2018 12:04
Tja, ohne sync() wird man nichts sehen
Böses Beispiel...

Pentalon
The Next
Web Engineer
16
Years of Service
User Offline
Joined: 3rd Dec 2007
Location: United Kingdom
Posted: 18th Feb 2018 14:25
@Pentalon

This is a English speaking forum, please post all public messages in English.
Windows 10, Intel i7 3.8 GHz, 16GB DDR3, NVIDIA GTX 780 4GB Superclocked

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 18th Feb 2018 15:02
Well a single type of selection box suitable for any platform might be difficult, but a mobile design will work on desktop just look weird I think. But a desktop design would be difficult to use on a mobile, so here's a mobile design.

Well nevermind. So I had made something for ya, but then the neighborhood lost power for hours and I lost it.


Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Pentalon
6
Years of Service
User Offline
Joined: 6th Feb 2018
Location:
Posted: 19th Feb 2018 07:36
Hey Phaelax

Thanks for trying to help.
I hope power is back on
And yes, i only need this for mobile.

Pentalon
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 19th Feb 2018 15:31
I'll try again tonight for you. This is the second time I've lost power for hours. Last week I saw transformers blow when it went out, I'm not sure what happened last time. I'll draw a quick example (im at work) of how I'll be doing it.

The list will be made up of several layers. You can do a real simple list with just 2 layers, the background window then text on top. Mine will be a little more complicated so you can decorate the window with whatever GUI graphics you want.

A. The background
B. Window border top
C. Window border middle (this will be tiled or stretched to fit the height of the list)
D. Window border bottom
E. Shadow effect

If you want a window that can be expanded in any direction (not just height as in my example) then you'll need at least 8 images; 4 corners plus the top, bottom, and 2 sides. The corners don't need to be tileable but the other 4 do to properly expand the window.

The "shadow effect" is a semi-transparent gradient that will go on top of the background and text and sit just below the top border and just above the bottom border. It'll give the illusion of text fading out slightly like you'd see on iPhone lists. see here

Layer 1 - the background
Layer 2 - text
Layer 3 - the window border and shadow effect


Whatever your background size is, you will clip/scissor the text to that area and position. This keeps the text contained to your list box and assists with scrolling.

Text can be contained in an array which will use to track which items are clicked on. An offset value (local to the list window) will be used to scroll the text. So if Y is 0, the first line of text is drawn at the top of the list. Scroll down (decrease Y) and now Y is maybe -20. So if your list window is located at [230,140], then your text will start at [230, 120]. And each item after the first just gets incremented by however much space you want between the text. And because it's all clipped to the background area, we don't need to worry about positioning outside of the window, you won't see it. When an item is clicked, you can change the text color or something.

That pretty much covers drawing the list box.

Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Attachments

Login to view attachments
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 21st Feb 2018 15:17 Edited at: 21st Feb 2018 15:18
I like writing GUI components

Ok, so this isn't 100% complete and I wrote it in notepad at work, try it at your own risk! But, you should get an idea of the logic and be able to understand how to implement additional functions to suit your needs. (like writing your own getAllSelectedItems function)

The way I have this set up should allow you to create and manage multiple lists at a time. Visual design is very simple compared to what I was trying to make for you before I lost power. A simple, semi-transparent white-colored sprite is used for the background of the list window. Text objects are created and positioned on top of that window, clipped to that sprite's area. The clipping region for the text is updated any time the position of the window is updated (when called through the appropriate function that is). The text is black but will be turned blue when you select an item (actual clicking isn't implemented in this code, i'll try to do this from home tonight if you haven't figured it out by then) The function I've written to select items is set up to toggle automatically. By default, everything is not selected.


Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Pentalon
6
Years of Service
User Offline
Joined: 6th Feb 2018
Location:
Posted: 21st Feb 2018 17:14
Hi Phaelax

Thank you very much for your Code.
I'll try to read/run it at the weekend...

Best Regards,
Pentalon
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 23rd Feb 2018 17:48 Edited at: 23rd Feb 2018 17:48
Ok, I worked on my example from above, which surprisingly needed little corrections considering I never attempted to compile it while writing.
There are a few hard-coded numbers in there which are related to the sprites I used. The list window in my example has a fixed width but the height can be adjusted. And because of the border around the window, I have hard-coded offsets. Other than that, it's pretty modular. The list allows for multiple selections and a function will easily return a list of the items selected.

What makes this so much easier to write in AppGameKit rather than DBP, is the pass by reference ability and being able to return arrays from functions.



Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Attachments

Login to view attachments
Pentalon
6
Years of Service
User Offline
Joined: 6th Feb 2018
Location:
Posted: 25th Feb 2018 12:13
OMG, that look difficult.
I am a bloody beginner with AppGameKit

I have copied your code and the pics into an empty project. It compiles but shows nothing (black screen).
I'll try to find out what's wrong

Thanks for your work and yout patience

Pentalon
xCept
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 25th Feb 2018 19:16
In an old AppGameKit photo editing app I made, I essentially recreated the original iOS List View selector. It was touch-scrollable with momentum, capable of multiple columns and selections, and could read in list data from an external JSON file. The basic premise was very similar to Phaelax's example. Unfortunately I can't recall how modular my code was for it at the time and it has been years.

Pentalon
6
Years of Service
User Offline
Joined: 6th Feb 2018
Location:
Posted: 26th Feb 2018 16:05
It works now, and it look s great.
Thanks for this very cool example.

Why do you give myList as argument by reference and not defining mylist as global ?

Pentalon
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Feb 2018 17:49
Technically, its safer than leaving something global. But it also allows the functions to be more modular and won't rely on a global having a specific name to work properly. And if you want more the 1 list, you won't have to alter anything.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Pentalon
6
Years of Service
User Offline
Joined: 6th Feb 2018
Location:
Posted: 27th Feb 2018 15:12
Ah, ok. This is a good argument

What tool do you use to make the borders/Frames for the exaple ?

Best regards,
Pentalon
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 27th Feb 2018 16:06
I used photoshop, but gimp is free.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Login to post a reply

Server time is: 2024-11-27 18:26:58
Your offset time is: 2024-11-27 18:26:58