Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.9.4] Creating Advanced GUI with ListBox
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 0
SKProCH

[1.9.4] Creating Advanced GUI with ListBox

By SKProCH, November 30, 2018 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

SKProCH    0

SKProCH

SKProCH    0

  • Tree Puncher
  • SKProCH
  • Members
  • 0
  • 4 posts
Posted November 30, 2018

It is necessary to create a mod that brings the system of stores to the game. For him, you need to make a fairly advanced interface. I do not understand how to make a ListBox that can be scrolled, how to add slots to it to put objects on when direct on it their tooltip showed up.
This is a quick sketch of how it should look.
 

WVRIa2uH-dQ.jpg

How to implement this?

 
  • Quote

Share this post


Link to post
Share on other sites

themaw    0

themaw

themaw    0

  • Stone Miner
  • themaw
  • Members
  • 0
  • 53 posts
Posted November 30, 2018

It looks great.

You should create a main guiscreen first.

Second,display playes's data at the top hub.

Third,design a  class of the data which will display at gui as a "BuyingItemTab".

Fourth,create a GUIdrawing class to handle the "BuyingItemTab" and display it.

You can not creeate a gui like this directly.

 

Or you can find some useful code at the minecraft code about the MODLIST OF MAIN MENU

  • Quote

Share this post


Link to post
Share on other sites

m00nl1ght    2

m00nl1ght

m00nl1ght    2

  • Tree Puncher
  • m00nl1ght
  • Members
  • 2
  • 22 posts
Posted November 30, 2018

I created a simple GuiList for my mod some time ago, it is based on the vanilla Gui classes. Maybe it helps. github

  • Like 1
  • Quote

Share this post


Link to post
Share on other sites

V0idWa1k3r    391

V0idWa1k3r

V0idWa1k3r    391

  • World Shaper
  • V0idWa1k3r
  • Members
  • 391
  • 1773 posts
Posted November 30, 2018

Any reason you are using 1.9? You should update to the latest version. 

You can see how the game handles it's own lists at GuiScrollingList.

Alternatively the algorithm is basically the following:

You have a variable that represents your scrollbar position, in a range of [0-1] {scrollbar}.

You have a scrollbar area itself, that starts at {startY} and spans {Height}

When the scrollbar is clicked interpolate the mouse coordinates relative to {startY} and {startY + Height} to a range of [0-1]. That is your new scrollbar position.

When the mouse wheel is scrolled your scrollbar position changes by a certain value, I would use {entriesFittingIntoTheBox} / {entries}.size(), then clamped to a range of [0-1].

So that is how you determine the scrollbar position. Next you have a collection of entries {entries} that is all of entries you have.

You can get the range of entries that are currently displayed as [{entries}.size() * {scrollbar}, {entries}.size() * {scrollbar} + {entriesFittingIntoTheBox}]. Obviously clamped to a [0-{entries}.size()]. Additionally if range[1] - range[0] is less than {entries}.size() and less than {entriesFittingIntoTheBox} then range[0] becomes range[0] - ({entriesFittingIntoTheBox} - (range[1] - range[0])). Again, clamp to [0-{entries}.size()]. Now expand the range by 1 keeping it in the [0-{entries}.size()] range.

Now you can start drawing your stuff. Start iterating the collection in the range you've just calculated. The position of element 0 will be {baseY} + ({elementY} - {elementIndex} * {unifiedElementSize}) <- this is assuming all your elements are of a unified height. The position of all next elements becomes {offsetY} + {baseY} where {offsetY} is either kept as a variable and added to or calculated as ({elementIndex} - range[0]) * {unifiedElementSize}.

The rendering of elements is up to you, I'm just telling you where to render them.

Now comes the interesting part - the stencil test. Stencil test is opengl's way of discarding fragments that don't fit into a defined scope. The stencil is it's separate buffer and can be of any shape but you are only interested in the basic quad for now. You can look up how to setup stencil rect or ask here - I will be able to provide you with a sample if you need it.

  • Like 2
  • Quote

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • diesieben07
      Do stuff right after login

      By diesieben07 · Posted 4 minutes ago

      PlayerLoggedInEvent
    • dotifo7120
      Do stuff right after login

      By dotifo7120 · Posted 20 minutes ago

      Is there an event called when a player enters into the world (fully logged)?
    • diesieben07
      Windows installer

      By diesieben07 · Posted 49 minutes ago

      Just use the installer, it is cross-platform.
    • T_Jam1
      Windows installer

      By T_Jam1 · Posted 52 minutes ago

      I need help!! I can't find the forge windows installer and every time I look something up it never helps, I'm mad, I'm confused, and I need help.
    • diesieben07
      Meine Inkompetenz kennt mal wieder keine Grenzen.(Forge 1.16.1)

      By diesieben07 · Posted 2 hours ago

      Threads merged. Please keep this forum in English.   Make sure your anti virus does not block the jar file. Also ensure you only download it from https://files.minecraftforge.net/.
  • Topics

    • dotifo7120
      1
      Do stuff right after login

      By dotifo7120
      Started 20 minutes ago

    • T_Jam1
      1
      Windows installer

      By T_Jam1
      Started 52 minutes ago

    • Mounty
      3
      Meine Inkompetenz kennt mal wieder keine Grenzen.(Forge 1.16.1)

      By Mounty
      Started 2 hours ago

    • Amperka_pro
      5
      Как применить нбт к предмету.

      By Amperka_pro
      Started 4 hours ago

    • MistyMarshes
      9
      [1.16.4] Get IChunk World / get current World for the overworld.

      By MistyMarshes
      Started 15 hours ago

  • Who's Online (See full list)

    • Lucie
    • Ugdhar
    • Maewolf04
    • MedHelm
    • Cyrus_Blaze
    • diesieben07
    • dotifo7120
    • ChampionAsh5357
    • Somonestolemyusername
    • Heliarco
    • Reflector_10
    • KillsBoostMyEgo
    • tf2_mandeokyi
    • Cutewarriorlover
    • DaiGamer117
    • glimmermaxcool
    • LexManos
    • Orbital_Gaming
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.9.4] Creating Advanced GUI with ListBox
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community