The library is fully functioning and I consider it final at the moment (it conaints everything [and more] that was intended when the work began). These ideas may be implemented someday but will not influence anything that is implemented right now.
Find good slider image (you may point me to one that is not copyrighted in any ways, preferable your own).
Make scrollbar clickable.
Make scrollspeed adjustable.
Enable mousewheel scrolling. <= cannot be done with just a library, might create a mod that uses this library later, won't be here but will be linked
Description
Ever had problems because the screenspace was too small for your map? No more! This library allows the creation of scrollbars to manage your content.
Pros:
unlimited space (100000 x 100000 is no problem for long scrollbars but going too far makes it hard to control, example with scrollheight 80000 included)
dynamically adjustable space
all 3 parts behave like normal dialog controls, except for the need to call the supplied functiosn (the names are similar to the original)
native:
Might keep the scrollbars in drag mode by leaving the game window at exactly the wrong moment (alt+tab for example). Fixed by clicking and/or moving the mouse over the bugging scrollbar icon.
Might not catch a mouse-out if the parent of the sliders is too small.
Copyable Example Code
At the moment, I use the following code for my map:
border_properties[2]borders;icon_properties[1]icons;scrollable_vertical_properties[1]scrollable_verticals;//this dialog is needed for the creation functionintscrollable_dialog;
Input data
voidinit_interface_borders(){borders[0].sizeTop=49;borders[0].sizeRight=5;borders[0].sizeBottom=5;borders[0].sizeLeft=5;borders[0].border="Assets\\Textures\\ui_ingame_resourcesharing_frame_message.dds";borders[0].imageType=c_triggerImageTypeHorizontalBorder;borders[0].borderColor=Color(100,100,100);borders[0].singleBorderImage="Assets\\Textures\\ui_ingame_resourcesharing_frame_message.dds";borders[0].singleBorderImageType=c_triggerImageTypeHorizontalBorder;borders[0].singleBorderColor=Color(100,100,100);borders[0].singleBorderWidth=3;borders[0].singleBorderMarginLeft=0;borders[0].singleBorderMarginRight=0;borders[0].singleBorderHeight=3;borders[0].singleBorderMarginTop=0;borders[0].singleBorderMarginBottom=0;borders[1].sizeTop=24;borders[1].sizeRight=36;borders[1].sizeBottom=22;borders[1].sizeLeft=35;borders[1].border="Assets\\Textures\\selectionframe_outer2.dds";borders[1].imageType=c_triggerImageTypeNineSlice;borders[1].borderColor=Color(100,100,100);borders[1].singleBorderImage="Assets\\Textures\\selectionframe_outer2.dds";borders[1].singleBorderImageType=c_triggerImageTypeNineSlice;borders[1].singleBorderColor=Color(100,100,100);borders[1].singleBorderWidth=35;borders[1].singleBorderMarginLeft=12;borders[1].singleBorderMarginRight=12;borders[1].singleBorderHeight=35;borders[1].singleBorderMarginTop=10;borders[1].singleBorderMarginBottom=10;}voidinit_interface_icons(){icons[0].image="Assets\\Textures\\btn-tips-sellprotossartifacts.dds";icons[0].imageType=c_triggerImageTypeNormal;icons[0].imageColor=Color(60,60,30);icons[0].width=38;icons[0].height=38;icons[0].marginTop=5;icons[0].marginRight=4;icons[0].marginBottom=5;icons[0].marginLeft=4;}voidinit_interface_scrollable_verticals(){scrollable_verticals[0].borderType=0;scrollable_verticals[0].iconProperties=0;scrollable_verticals[0].width=200;//These dimension determine the size of the content area. Everything else will change accordingly.scrollable_verticals[0].height=600;}voidinit_interface_scrollable_dialog(){scrollable_dialog=DialogCreate(1,1,1,1,1,false);DialogSetFullscreen(scrollable_dialog,true);DialogSetImageVisible(scrollable_dialog,false);DialogSetVisible(scrollable_dialog,c_allPlayers,true);}
//THIS FUNCTION HAS TO BE EXECUTED once before scrollables can be createdvoidinit_scrollableCreation(){init_interface_borders();init_interface_icons();init_interface_scrollable_verticals();init_interface_scrollable_dialog();}intmyScrollable=scrollable_new("myScrollable");//THIS FUNCTION HAS TO BE EXECUTEDvoidcreateMyScrollable(){intidOfScrollableVerticals=0;intidOfScrollable=myScrollable;init_interface_scrollable_vertical_create(idOfScrollable,idOfScrollableVerticals);}
Adding content
(this is only a dummy, you have to add your own content instead)
voidinit_interface_fakeContent(intid){intfakeContent=DialogControlCreateInPanel(scrollable_getContentPanel(id),c_triggerControlTypeLabel);inti;stringcontent;DialogControlSetSize(fakeContent,c_allPlayers,68,18165);DialogControlSetPropertyAsString(fakeContent,c_triggerControlPropertyStyle,c_allPlayers,"ModRightSize16");DialogControlSetPositionRelative(fakeContent,c_allPlayers,c_anchorTopLeft,scrollable_getRelativeControl_top(id),c_anchorTopLeft,0,0);content="";for(i=1;i<=1000;i+=1){content+=IntToString(i)+":\n";}DialogControlSetPropertyAsText(fakeContent,c_triggerControlPropertyText,c_allPlayers,StringToText(content));scrollable_contentBox_setVerticalContentSize(id,c_allPlayers,18150);}//THIS FUNCTION HAS TO BE EXECUTEDvoidaddFakeContent(){init_interface_fakeContent(myScrollable);}
Putting everything together.
(each step is copy/pasted below the previous one)
structborder_properties{intsizeTop;intsizeRight;intsizeBottom;intsizeLeft;stringborder;intimageType;colorborderColor;stringsingleBorderImage;intsingleBorderImageType;colorsingleBorderColor;intsingleBorderWidth;intsingleBorderMarginLeft;intsingleBorderMarginRight;intsingleBorderHeight;intsingleBorderMarginTop;intsingleBorderMarginBottom;};structicon_properties{stringimage;intimageType;colorimageColor;intwidth;intheight;intmarginTop;intmarginRight;intmarginBottom;intmarginLeft;};structscrollable_vertical_properties{intborderType;inticonProperties;intwidth;intheight;};border_properties[2]borders;icon_properties[1]icons;scrollable_vertical_properties[1]scrollable_verticals;//this dialog is needed for the creation functionintscrollable_dialog;voidinit_interface_borders(){borders[0].sizeTop=49;borders[0].sizeRight=5;borders[0].sizeBottom=5;borders[0].sizeLeft=5;borders[0].border="Assets\\Textures\\ui_ingame_resourcesharing_frame_message.dds";borders[0].imageType=c_triggerImageTypeHorizontalBorder;borders[0].borderColor=Color(100,100,100);borders[0].singleBorderImage="Assets\\Textures\\ui_ingame_resourcesharing_frame_message.dds";borders[0].singleBorderImageType=c_triggerImageTypeHorizontalBorder;borders[0].singleBorderColor=Color(100,100,100);borders[0].singleBorderWidth=3;borders[0].singleBorderMarginLeft=0;borders[0].singleBorderMarginRight=0;borders[0].singleBorderHeight=3;borders[0].singleBorderMarginTop=0;borders[0].singleBorderMarginBottom=0;borders[1].sizeTop=24;borders[1].sizeRight=36;borders[1].sizeBottom=22;borders[1].sizeLeft=35;borders[1].border="Assets\\Textures\\selectionframe_outer2.dds";borders[1].imageType=c_triggerImageTypeNineSlice;borders[1].borderColor=Color(100,100,100);borders[1].singleBorderImage="Assets\\Textures\\selectionframe_outer2.dds";borders[1].singleBorderImageType=c_triggerImageTypeNineSlice;borders[1].singleBorderColor=Color(100,100,100);borders[1].singleBorderWidth=35;borders[1].singleBorderMarginLeft=12;borders[1].singleBorderMarginRight=12;borders[1].singleBorderHeight=35;borders[1].singleBorderMarginTop=10;borders[1].singleBorderMarginBottom=10;}voidinit_interface_icons(){icons[0].image="Assets\\Textures\\btn-tips-sellprotossartifacts.dds";icons[0].imageType=c_triggerImageTypeNormal;icons[0].imageColor=Color(60,60,30);icons[0].width=38;icons[0].height=38;icons[0].marginTop=5;icons[0].marginRight=4;icons[0].marginBottom=5;icons[0].marginLeft=4;}voidinit_interface_scrollable_verticals(){scrollable_verticals[0].borderType=0;scrollable_verticals[0].iconProperties=0;//These dimension determine the size of the content area. Everything else will change accordingly.scrollable_verticals[0].width=200;scrollable_verticals[0].height=600;}voidinit_interface_scrollable_dialog(){scrollable_dialog=DialogCreate(1,1,1,1,1,false);DialogSetFullscreen(scrollable_dialog,true);DialogSetImageVisible(scrollable_dialog,false);DialogSetVisible(scrollable_dialog,c_allPlayers,true);}voidinit_interface_scrollable_vertical_create(intid,intproperties){structref<scrollable_vertical_properties>svp=scrollable_verticals[properties];structref<border_properties>bp=borders[svp.borderType];structref<icon_properties>ip=icons[svp.iconProperties];intbox;intdivider;intdividerPanel;scrollable_contentBox_create(id,scrollable_dialog,false);scrollable_contentBox_setSize(id,c_allPlayers,svp.width,svp.height);scrollable_contentBox_setBorderSize(id,c_allPlayers,bp.sizeTop,bp.sizeRight+bp.singleBorderWidth-bp.singleBorderMarginLeft-bp.singleBorderMarginRight+ip.width-ip.marginLeft-ip.marginRight,bp.sizeBottom,bp.sizeLeft);scrollable_contentBox_setBorderImage(id,c_allPlayers,bp.border,bp.imageType,bp.borderColor);scrollable_contentBox_setBackgroundImageVisible(id,c_allPlayers,false);scrollable_contentBox_setPosition(id,c_allPlayers,c_anchorTopLeft,50,50);box=scrollable_getContentPanel(id);scrollable_verticalSlider_create(id,scrollable_dialog,false);scrollable_verticalSlider_setSize(id,c_allPlayers,ip.width,svp.height+ip.marginTop+ip.marginBottom);scrollable_verticalSlider_setSliderImage(id,c_allPlayers,ip.image,ip.imageType,ip.imageColor);scrollable_verticalSlider_setBackgroundImageVisible(id,c_allPlayers,false);scrollable_verticalSlider_setPositionRelative(id,c_allPlayers,c_anchorBottomRight,scrollable_contentBox_relative(id),c_anchorBottomRight,ip.marginBottom-bp.sizeRight,ip.marginBottom-bp.sizeBottom);dividerPanel=DialogControlCreate(scrollable_dialog,c_triggerControlTypePanel);DialogControlSetSize(dividerPanel,c_allPlayers,bp.singleBorderWidth,svp.height+bp.singleBorderMarginTop+bp.singleBorderMarginBottom);DialogControlSetPositionRelative(dividerPanel,c_allPlayers,c_anchorBottomRight,scrollable_contentBox_relative(id),c_anchorBottomRight,ip.marginLeft-ip.width+ip.marginRight-bp.sizeRight+bp.singleBorderMarginRight,bp.singleBorderMarginBottom-bp.sizeBottom);divider=DialogControlCreateInPanel(dividerPanel,c_triggerControlTypeImage);DialogControlSetPropertyAsString(divider,c_triggerControlPropertyImage,c_allPlayers,bp.singleBorderImage);DialogControlSetPropertyAsInt(divider,c_triggerControlPropertyImageType,c_allPlayers,bp.singleBorderImageType);DialogControlSetFullDialog(divider,c_allPlayers,true);}//init_scrollableCreation() has to be called once before scrollables can be createdvoidinit_scrollableCreation(){init_interface_borders();init_interface_icons();init_interface_scrollable_verticals();init_interface_scrollable_dialog();}intmyScrollable=scrollable_new("myScrollable");voidcreateMyScrollable(){intidOfScrollableVerticals=0;intidOfScrollable=myScrollable;init_interface_scrollable_vertical_create(idOfScrollable,idOfScrollableVerticals);}voidinit_interface_fakeContent(intid){intfakeContent=DialogControlCreateInPanel(scrollable_getContentPanel(id),c_triggerControlTypeLabel);inti;stringcontent;DialogControlSetSize(fakeContent,c_allPlayers,68,18165);DialogControlSetPropertyAsString(fakeContent,c_triggerControlPropertyStyle,c_allPlayers,"ModRightSize16");DialogControlSetPositionRelative(fakeContent,c_allPlayers,c_anchorTopLeft,scrollable_getRelativeControl_top(id),c_anchorTopLeft,0,0);content="";for(i=1;i<=1000;i+=1){content+=IntToString(i)+":\n";}DialogControlSetPropertyAsText(fakeContent,c_triggerControlPropertyText,c_allPlayers,StringToText(content));scrollable_contentBox_setVerticalContentSize(id,c_allPlayers,18150);}voidaddFakeContent(){init_interface_fakeContent(myScrollable);}voidexecuteEverything(){init_scrollableCreation();createMyScrollable();addFakeContent();}
The function "ececuteEverything" calls all three functions that are marked as "THIS HAS TO BE EXECUTED". Using it instead of executing them is optional.
HINT: I just found out that textcontent scales different depending screen resolutions. The dialog items have the same size, but the text that is displayed gets bigger/smaller (in comparison?). The example might look odd but this will NOT happen when you add multiple dialog items as content instead of one.
Results:
(might use different width/height than in the default example)
borderType = 0:
borderType = 1:
(I still don't have any good slider images, so I just use the same as in type 1.)
The library is currently in its final version. However, if a bug or desireable functionality is found, it will probably get another update.
All working copies will stay as attachment for post 1.
The example will always use the newest version.
All changes will be listed here:
Changelog
0.002:
fixed a bug where the x position of the content was partly computed using the values for y
(reason for removal of scrollable_0.001.SC2Lib)
added more visibility options to hide specific parts
added functions to control the scroll position through triggers
deallocating now possible
0.003:
a function "void funcname(int newX, newY)" can be registered to be called on scroll end
functionality was added to get the current content scroll position for a player
0.004:
fixed a bug where deallocation broke the stack/active instances in some cases
(reason for removal of scrollable_0.002.SC2Lib / scrollable_0.003.SC2Lib)
added functionality to force a player into scroll mode for any number of scrolalbles
cleaned up varspace - memory usage down by 60%
0.005:
added dummy function for importing
0.006:
removed a bug that sometimes crashed the update thread when changing the scrollposition of the content through triggers while the content was smaller than the content box
(reason for removal of scrollable_0.004.SC2Lib / scrollable_0.005.SC2Lib)
0.007:
restructured the whole function interface
borders now optional
background now optional (black if not hidden)
positioning system reworked (relative controls now unified)
removed a bug that sometimes skipped the player with the highest number in a playergroup
slider background now grey by default (can now be distinguished from the content box background)
slider image now optional (white by default)
removed excessive error messages and checking for correctness that might prevent some adjustments (for example negative border sizes)
0.008:
removed additional inputs from the "setSize" functions for sliders
This is an awesome script. Looks really useful. From running the example map, it looks really good. It also appears to fit the submission guidelines.
!!! WARNING. THE FOLLOWING MAY OR MAY NOT CONSIST OF OPINIONS !!!
Unfortunately, it seems much too complicated to actually test within a reasonable amount of time! Well, maybe for a dummy like me. My eyes glaze over when I read step 1 of the step-by-step guide. So I suggest streamlining the library a bit so it's more noob-friendly.
To be honest, I would love to try and implement something like this in a map, but I'm afraid the time investment required to parse how it works is simply not worth it. Either work on your explanation or make the library more user-friendly.
As far as the actual features go, it does pretty much what you need it to do. Adding the ability to click on the empty space in the scroll bar to quickly jump to that point would be a nice addition (seems like you have that already planned, though.)
Anyway, I'm going to add it to the category list. Thanks for the submission.
Unfortunately, it seems much too complicated to actually test within a reasonable amount of time! Well, maybe for a dummy like me. My eyes glaze over when I read step 1 of the step-by-step guide. So I suggest streamlining the library a bit so it's more noob-friendly.
To be honest, I would love to try and implement something like this in a map, but I'm afraid the time investment required to parse how it works is simply not worth it. Either work on your explanation or make the library more user-friendly.
You are not the first person to tell me this and I admid that the way it is made is rather unfriendly. At the moment you have to supply all the information up front, even optional stuff.
Even though a library is not supposed to be work in progress, splitting up inputs is an update that will definitely come.
Thank you for the feedback on the step to step guide. Since It will be reworked anyways, I will remove it now and replace it with an easier version later.
As far as the actual features go, it does pretty much what you need it to do. Adding the ability to click on the empty space in the scroll bar to quickly jump to that point would be a nice addition (seems like you have that already planned, though.)
Not at the moment but it's a good idea. This is not an easy feat since I work without any knowledge about screen/ui resolution but just thinking about it gives me a few ideas.
Changes will probably not happen till the end of the week, my schedule is rather busy.
I think a good ideal to strive toward would be to have it resemble scroll bars that exist everywhere else (like your internet browser, for example.) It's a convention that everyone is already used to and probably expects from scroll bar functionality. The only other thing that is missing right now, other than jumping to a section, is the increment buttons at the top and bottom. There's also mouse scroll but I'm not sure implementing that would even be possible.
Is it possible to catch mousewheel up and down in sc2?
If so, it is no problem.
I do not intend to implement up and down buttons. Reducing the scrollbar size greatly reduces the level of control over the content. However, you can set or modify (in-/decrase) the scrollposition through triggers. This allows you to create buttons with exactly the functionality you want.
@BasharTeg: Go
Is it possible to catch mousewheel up and down in sc2?
If so, it is no problem.
I remember a looong time ago I wanted to get a grip on mousewheel rotation. So what I did was, creating a loot of different instances in the default camera with only a very slightly different pitch values. You can then via trigger register that change in pitch and reset the camera pitch. If the change is small enough, you will not really notice. Downside is, you cannot use the mousewheel to camera scroll anymore (but you propably don't want to anyway, if you use the mousewheel for something else).
That is actually really useful. That might become my method of choice. However, not in this library. Since it changes data stuff, a mod using this library will be needed.
Another library I'm planning will allow users to move everything on their screen (and maybe resizing stuff as well). I am not sure what comes first or whether it will be created at all.
Is it possible to catch mousewheel up and down in sc2?
If so, it is no problem.
I do not intend to implement up and down buttons. Reducing the scrollbar size greatly reduces the level of control over the content. However, you can set or modify (in-/decrase) the scrollposition through triggers. This allows you to create buttons with exactly the functionality you want.
Not possible. We have requested that months ago and Blizzard stated that "It was a good idea and might be added in the future", or something along those lines.
It's a pity how little blizz cares about these things. It should be easy enough to implement.
Especially considering how much possiblities this would open and that they already have support for detecting mouse wheel PRESS which seems way more uncommon than scrolling. :)
I have separated most of the combination functions and made everything more similar to the basic dialog control functions. I am still not good at creating tutorials so I'd be really thankful on your input:
Where did you get stuck.
What was hard to grasp (even if you understood it in the end).
Is something misleadin?
Did I forget to mention any steps?
Do any error messages appear while testing (and are they useful?)?
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Scrollable
Ideas
The library is fully functioning and I consider it final at the moment (it conaints everything [and more] that was intended when the work began). These ideas may be implemented someday but will not influence anything that is implemented right now.
Enable mousewheel scrolling.<= cannot be done with just a library, might create a mod that uses this library later, won't be here but will be linkedDescription
Ever had problems because the screenspace was too small for your map? No more! This library allows the creation of scrollbars to manage your content.
Pros:
native:
Cons:
Copyable Example Code
At the moment, I use the following code for my map:
Data structures
Create instances of those
Input data
Creation function
Creating a scrollable:
Adding content
(this is only a dummy, you have to add your own content instead)
Putting everything together.
(each step is copy/pasted below the previous one)
The function "ececuteEverything" calls all three functions that are marked as "THIS HAS TO BE EXECUTED". Using it instead of executing them is optional.
HINT: I just found out that textcontent scales different depending screen resolutions. The dialog items have the same size, but the text that is displayed gets bigger/smaller (in comparison?). The example might look odd but this will NOT happen when you add multiple dialog items as content instead of one.
Results:
(might use different width/height than in the default example)
(I still don't have any good slider images, so I just use the same as in type 1.)
Installation
Example Map
The example shows of how powerful of a tool this is but is not as visually pleasing. Download Example Map
The library does not cause the load time. The example includes more than 10000 dialog controls.
Searching for border images?
Click me!
The library is currently in its final version. However, if a bug or desireable functionality is found, it will probably get another update.
All working copies will stay as attachment for post 1.
The example will always use the newest version.
All changes will be listed here:
Changelog
(reason for removal of scrollable_0.001.SC2Lib)
(reason for removal of scrollable_0.002.SC2Lib / scrollable_0.003.SC2Lib)
(reason for removal of scrollable_0.004.SC2Lib / scrollable_0.005.SC2Lib)
This is an awesome script. Looks really useful. From running the example map, it looks really good. It also appears to fit the submission guidelines.
!!! WARNING. THE FOLLOWING MAY OR MAY NOT CONSIST OF OPINIONS !!!
Unfortunately, it seems much too complicated to actually test within a reasonable amount of time! Well, maybe for a dummy like me. My eyes glaze over when I read step 1 of the step-by-step guide. So I suggest streamlining the library a bit so it's more noob-friendly.
To be honest, I would love to try and implement something like this in a map, but I'm afraid the time investment required to parse how it works is simply not worth it. Either work on your explanation or make the library more user-friendly.
As far as the actual features go, it does pretty much what you need it to do. Adding the ability to click on the empty space in the scroll bar to quickly jump to that point would be a nice addition (seems like you have that already planned, though.)
Anyway, I'm going to add it to the category list. Thanks for the submission.
You are not the first person to tell me this and I admid that the way it is made is rather unfriendly. At the moment you have to supply all the information up front, even optional stuff. Even though a library is not supposed to be work in progress, splitting up inputs is an update that will definitely come.
Thank you for the feedback on the step to step guide. Since It will be reworked anyways, I will remove it now and replace it with an easier version later.
Not at the moment but it's a good idea. This is not an easy feat since I work without any knowledge about screen/ui resolution but just thinking about it gives me a few ideas.
Changes will probably not happen till the end of the week, my schedule is rather busy.
@Arkless: Go
I think a good ideal to strive toward would be to have it resemble scroll bars that exist everywhere else (like your internet browser, for example.) It's a convention that everyone is already used to and probably expects from scroll bar functionality. The only other thing that is missing right now, other than jumping to a section, is the increment buttons at the top and bottom. There's also mouse scroll but I'm not sure implementing that would even be possible.
@BasharTeg: Go
Is it possible to catch mousewheel up and down in sc2?
If so, it is no problem.
I do not intend to implement up and down buttons. Reducing the scrollbar size greatly reduces the level of control over the content. However, you can set or modify (in-/decrase) the scrollposition through triggers. This allows you to create buttons with exactly the functionality you want.
I remember a looong time ago I wanted to get a grip on mousewheel rotation. So what I did was, creating a loot of different instances in the default camera with only a very slightly different pitch values. You can then via trigger register that change in pitch and reset the camera pitch. If the change is small enough, you will not really notice. Downside is, you cannot use the mousewheel to camera scroll anymore (but you propably don't want to anyway, if you use the mousewheel for something else).
@Elmaex: Go
That is actually really useful. That might become my method of choice. However, not in this library. Since it changes data stuff, a mod using this library will be needed.
Another library I'm planning will allow users to move everything on their screen (and maybe resizing stuff as well). I am not sure what comes first or whether it will be created at all.
Not possible. We have requested that months ago and Blizzard stated that "It was a good idea and might be added in the future", or something along those lines.
@Mille25: Go
It's a pity how little blizz cares about these things. It should be easy enough to implement.
Especially considering how much possiblities this would open and that they already have support for detecting mouse wheel PRESS which seems way more uncommon than scrolling. :)
I have separated most of the combination functions and made everything more similar to the basic dialog control functions. I am still not good at creating tutorials so I'd be really thankful on your input: