From 20f0efdcb8af2d7ea2684762e695f460c5d75f34 Mon Sep 17 00:00:00 2001 From: Bottinator22 <59987380+Bottinator22@users.noreply.github.com> Date: Wed, 18 Dec 2024 22:34:58 -0800 Subject: [PATCH] add shader interface --- .../opensb/interface/opensb/shaders/body.png | Bin 0 -> 743 bytes .../interface/opensb/shaders/categoryname.png | Bin 0 -> 391 bytes .../interface/opensb/shaders/footer.png | Bin 0 -> 163 bytes .../opensb/interface/opensb/shaders/group.png | Bin 0 -> 80 bytes .../interface/opensb/shaders/groupback.png | Bin 0 -> 162 bytes .../interface/opensb/shaders/header.png | Bin 0 -> 4346 bytes .../interface/opensb/shaders/optionname.png | Bin 0 -> 197 bytes .../interface/opensb/shaders/shaders.config | 147 ++++++++++++ .../interface/opensb/shaders/shaders.lua | 219 ++++++++++++++++++ 9 files changed, 366 insertions(+) create mode 100644 assets/opensb/interface/opensb/shaders/body.png create mode 100644 assets/opensb/interface/opensb/shaders/categoryname.png create mode 100644 assets/opensb/interface/opensb/shaders/footer.png create mode 100644 assets/opensb/interface/opensb/shaders/group.png create mode 100644 assets/opensb/interface/opensb/shaders/groupback.png create mode 100644 assets/opensb/interface/opensb/shaders/header.png create mode 100644 assets/opensb/interface/opensb/shaders/optionname.png create mode 100644 assets/opensb/interface/opensb/shaders/shaders.config create mode 100644 assets/opensb/interface/opensb/shaders/shaders.lua diff --git a/assets/opensb/interface/opensb/shaders/body.png b/assets/opensb/interface/opensb/shaders/body.png new file mode 100644 index 0000000000000000000000000000000000000000..272ed29cb23d057e6c369893881c006c880ec096 GIT binary patch literal 743 zcmeAS@N?(olHy`uVBq!ia0y~yV4MJCpWt8vlE*~1KVo2DTIcEF7*cWT?R9IeW(SeB zKyK~jeDD0d%?r&9mvWn|Twl7%fum)HfMS2K*UVS$KaZ73v^};t-`6EV* zcb<8(Z4Pstb6VMBi+Q(BH%Glr63b({6wSC}xhW$96H`M2gMtDB2L}j|%{!!i`ph{l z1%(e=It-Zp94L?RirgM2!P>HY#a6wrhV}d&@A+98?s8IK1Ig}$cnant8t~K@92^(~ z1Q=LY7#JCWh^9QSC2$*P%!7FfVjltCH?9*VzI!bzrhaGtcV1H9sHTU#+rwU90%q`Z L^>bP0l+XkKH!ORL literal 0 HcmV?d00001 diff --git a/assets/opensb/interface/opensb/shaders/categoryname.png b/assets/opensb/interface/opensb/shaders/categoryname.png new file mode 100644 index 0000000000000000000000000000000000000000..3019556043a9c3036ecc8f33573cfd6e6a496beb GIT binary patch literal 391 zcmV;20eJq2P)TrR426xA+w~lrYR=K?AhAJ$B^{{?q_~*;Ie}Sp8R>meCQS0|I7Uyn*Xt$JFbqSU z^Puuf*PQls=CW7C@l8iLUz5LDd(d%HhwiA1YaM;4xzrbC=1>!*T(L&ZIyQCJcVoWi zBU2ySoar1&`5$^!-Hqb>q%$>9+f!=Z3s>({#GgaXas4r~zn+D{+NJS98{#AmUo;fg zyxep?=A)$b63!vrlN?JqR!ZzczEsm05c8YbN%CF%L%uxB8s#<0cQ{iQO>?)TE4?zY z)fughO#Qx`-}cn#=tIpmuEpukIF8>00O*SI(+IJfdS|c^{!i%<&9PV&>!kuH_tP^zyNfJde=?U1Oo%m lA?jUs9EV3M0O$|(?jH(LP24s+jGzDj002ovPDHLkV1ifNxI+K{ literal 0 HcmV?d00001 diff --git a/assets/opensb/interface/opensb/shaders/footer.png b/assets/opensb/interface/opensb/shaders/footer.png new file mode 100644 index 0000000000000000000000000000000000000000..426f8a6352da4b45c41074454618864c15284320 GIT binary patch literal 163 zcmeAS@N?(olHy`uVBq!ia0y~yV4MJC^K-BP$x}aOz5`NOo-U3d6}R4AJ;-^$fQQAg ze963!eX~6-oadKJ`p;BsaQ#rO>~Y>R>34;b&xgV5OkMbRg8`S_cOwL#)NNk1w2<7zopr0L4->nE(I) literal 0 HcmV?d00001 diff --git a/assets/opensb/interface/opensb/shaders/group.png b/assets/opensb/interface/opensb/shaders/group.png new file mode 100644 index 0000000000000000000000000000000000000000..66f5cdb3e8491ddf26d0453112042f3ab852c6cc GIT binary patch literal 80 zcmeAS@N?(olHy`uVBq!ia0vp^O+YNb2qYLjU7IBVq{Ka4978H@CI9GW<1;WZSisaS csL~`T#c-iQ`{C`Dh(eH3Pgg&ebxsLQ0KCZ*fdBvi literal 0 HcmV?d00001 diff --git a/assets/opensb/interface/opensb/shaders/groupback.png b/assets/opensb/interface/opensb/shaders/groupback.png new file mode 100644 index 0000000000000000000000000000000000000000..ed838f3cdaa699d9e46ec9aacdf8b3c9c1cc372d GIT binary patch literal 162 zcmeAS@N?(olHy`uVBq!ia0vp^O+YNb0VEjyAN!FBq%u8S978H@y`5?()S$q_V$Spa zN_*tbi*sBZ5@fPx85}5_oo4+ib?Fp~Ez4b_HrjETEuP14;_lOR^VaS3JF&FwLwVFr z#+DA-{rgPE<`Lnf|S_DC6y9=C!2r_Lm9A|2h;Pc7Pwa4Ml(fZ;w zav>Wr;75?yhe7Xe(~hE=>sK=DjkbMa)|qGYow=>+yzLua` z|9CmKPnY*~3cD`xi@}|XmSjEjd+eQ7@-&HMB|Mzl>~6lh^Tz8NF3h7>Nxrh~8y%$| z^&RSsYKE3R9avd>96A43x-tF5mxmqAZ!e|%e`YTF;)&NqJ8}qd%@8=vyQDRYIfz!xrBbUc`wuJa%EM`+vHt*R{K2Dw)R@0Cv$7Y zukyS8`pGBVzW2M1m6ax!=B8dps%ynUc}v=NJ2T4Ph>0J!Mz1W44j_9=xLxn>oMAX; zdimnEHsZjhZ(nFaH>JL=d9#PUurz!6KZj~sk#z%Uwv*p|{1oTK%TqK>Z@B$!rlF*v zp8Y|w@7FDdHXTTND*fIzIrp>tgUc2ksn&HYAM9y+^5m)X?xthX+-3Hjoc(z=PgbdM z&)1I}?#}7QPnAF4#aua0Jf3lRJ2-eI%az%@rg6qC+RW$nCEYf&yrytDFRb|D^F`I) zroEOSm2{mr)W8@{99(pL?uKa9_WieaK2xC8bXrbz&wuyGtXFoo{CE9VmP_gAaLU?? zzk9GVv1h~9zOU{dT5@0IZLhxipZnihD84p5WyOM*vO5Yl@Au|R8>slklZe*ON;y#1 zS@XZ@YsmTM{?apB6g7|U%zofp|G7{5`fk|ITpUQA-y$_?PJK`URTmSWy4HABGF&*Q zWBITT=wd+;$__znD`FzcRRJ0GfeImH#|Ao%V5q>`u~MUl^oR~nDHPO8ps0RTF;`#3 zS$S;59a>wAfdD}uvuG?B2t}Bf9aC``I9ALAhN>=dl^t8-@uH5f1W<#{pd)ctOsJ)? zJG7`x;{8maGj9|EzS*%#Sr!?Bh(@Ejs9qPADhSGIwGt#v&@>J`@JL-qW@C6LvP6Lx z!Ek~ICkdh~ghQx;$@;=IvK_t=M-ssx5g!qeU9}Ko zG@&1ih!n#^N)&=fxJKfDs}_XhCGikEHy$t6NCCARo+Cg21fgpLu1ZZ zMjcWdsppJ-8V44O88;YdKW+uA4+lOyYotgM&H1=ED0e6#vmp*BP!L=vKpZQ_lB~sQ zhJh9uHvnM7Sv||*W&r%Gk)%y}pFa-bUP*weWCQV8DNsCw;vo)c&|7fc%$sn79;(Bl zXDOVtS`9`MPtiUKs8Bq|WL-DIvnv0$$A%VvS63 zm29X2!0s_B*D<^B15%(_pU+5{Ot{GmRbU{29%p?}6h^CFPg+d89&nb4=#j8rjl6sVe?d`rS=yV>-wrQYNxpmXo$8efx$5Y65RPVw1!WNgnU$`5ry;xA=R;$%?Dn{l z|CN%Ss3Fd-EqVl+o^?BOi(?;N`k-rO0+sscdkcDRePxTh?VIf_34e0z9^8k0*|>H0 zU|)4h9Oez+nd@C zCp63x)*~;zbl37!WQRtBBqTI6ASjB!;ZJ!RZ2enPleNEh88Tc_b*VP_-v!u5Eomu~ PQli_n%6agv`x^fb1g{X# literal 0 HcmV?d00001 diff --git a/assets/opensb/interface/opensb/shaders/optionname.png b/assets/opensb/interface/opensb/shaders/optionname.png new file mode 100644 index 0000000000000000000000000000000000000000..f7c45002b58b96fe8debb76af4a9e10e8d11992e GIT binary patch literal 197 zcmeAS@N?(olHy`uVBq!ia0vp^A3$slHXu1Y@^L7T>hW}O45_&F_SQyDCPxw1i!T#4 zajM-6J9FmE0k@nZ4uUSJjv_8P7t*tscU3iAKDhtl@1;{dJy;(5NaS_IQ6n+Ke#yzt zPq6kh{0#fP b.name end +local function alphabeticalNameSortLesser(a, b) return a.name < b.name end +local sortedGroups = {} +local groups = {} + +local widgetsToGroups = {} +local allSettings = {} + +local function addGroupToList(data) + local name = widget.addListItem(GROUP_LIST_WIDGET) + widget.setText(fmt("%s.%s.button", GROUP_LIST_WIDGET, name), data.friendlyName) + log("Added group ^cyan;%s^reset; to list", data.friendlyName) + return name +end + +local function parseGroups() + for name, data in next, renderer.postProcessGroups() do + if not data.hidden then + if not data.friendlyName then data.friendlyName = name end + data.groupId = name + data.name = data.friendlyName + groups[data.groupId] = data + end + end + + for groupId, data in pairs(groups) do + sortedGroups[#sortedGroups + 1] = data + end + table.sort(sortedGroups, alphabeticalNameSortLesser) + for i = 1, #sortedGroups do + local data = sortedGroups[i] + data.index = i + local name = addGroupToList(data) + data.widget = name + widgetsToGroups[name] = data + end + if sortedGroups[1] then + local first = sortedGroups[1].widget + widget.setListSelected(GROUP_LIST_WIDGET, first) + selectGroup(first) + end +end + +local activeGroup + +local function addOptionGroup(data, i, added) + local y = (i - 1) * -14 + local bg = { + type = "image", + file = PATH .. "groupname.png", + position = {-12, y} + } + local name = "group_" .. i + widget.addChild(BINDS_WIDGET, bg, name) + added[#added + 1] = name + local label = { + type = "label", + value = data.name, + wrapWidth = 120, + fontSize = 8, + hAnchor = "mid", + vAnchor = "mid", + position = {120, 6} + } + widget.addChild(fmt("%s.%s", BINDS_WIDGET, name), label, "text") +end + +local function addOption(data, i, added) + local y = (i - 1) * -14 + local bg = { + type = "image", + file = PATH .. "optionname.png", + position = {-12, y} + } + local name = "label_" .. i + widget.addChild(OPTIONS_WIDGET, bg, name) + added[#added + 1] = name + local label = { + type = "label", + value = data.name, + wrapWidth = 120, + fontSize = 8, + hAnchor = "mid", + vAnchor = "mid", + position = {62, 6} + } + widget.addChild(fmt("%s.%s", OPTIONS_WIDGET, name), label, "text") + -- todo: finish this +end + +local function addEnabled(groupname, i, added) + local y = (i - 1) * -14 + local bg = { + type = "image", + file = PATH .. "optionname.png", + position = {-12, y} + } + local name = "label_" .. i + widget.addChild(OPTIONS_WIDGET, bg, name) + added[#added + 1] = name + local label = { + type = "label", + value = "Enabled", + wrapWidth = 120, + fontSize = 8, + hAnchor = "mid", + vAnchor = "mid", + position = {62, 6} + } + widget.addChild(fmt("%s.%s", OPTIONS_WIDGET, name), label, "text") + local checkbox = { + type = "button", + callback = "toggleGroupEnabled", + position = {165, y + 2}, + pressedOffset = {0, 0}, + base = "/interface/optionsmenu/checkboxnocheck.png", + hover = "/interface/optionsmenu/checkboxnocheckhover.png", + baseImageChecked = "/interface/optionsmenu/checkboxcheck.png", + hoverImageChecked = "/interface/optionsmenu/checkboxcheckhover.png", + checkable = true, + checked = renderer.postProcessGroupEnabled(groupname) + } + name = "check_"..groupname + added[#added + 1] = name + widget.addChild(OPTIONS_WIDGET, checkbox, name) +end + +function toggleGroupEnabled(checkbox, cdata) + renderer.setPostProcessGroupEnabled(activeGroup, widget.getChecked(fmt("%s.%s",OPTIONS_WIDGET,checkbox)), true) +end + +function selectGroup() + local selected = widget.getListSelected(GROUP_LIST_WIDGET) + local group = widgetsToGroups[selected] + local dataFromPrev = widget.getData(OPTIONS_WIDGET) + if dataFromPrev then + for i, v in pairs(dataFromPrev) do + widget.removeChild(OPTIONS_WIDGET, v) + end + end + widgetsToOptions = {} + + activeGroup = group.groupId + + local bannerOptions = widget.bindCanvas("banner") + bannerOptions:clear() + + local bannerName = tostring(group.bannerName or group.name or group.groupId) + bannerOptions:drawText(bannerName, {position = {127, 13}, horizontalAnchor = "mid", verticalAnchor = "mid"}, 16) + + local added = {} + local index = 0 + addEnabled(group.groupId,index,added) + + --[[ + local categories = group.categories or {} + if not categories.unsorted then + categories.unsorted = {name = "Unsorted"} + end + + local sortedCategories = {} + for categoryId, data in pairs(categories) do + data.name = tostring(data.name or categoryId) + data.sortedOptions = {} + sortedCategories[#sortedCategories + 1] = data + end + + table.sort(sortedCategories, alphabeticalNameSortLesser) + + for categoryId, data in pairs(categories) do + table.sort(data.sortedOptions, alphabeticalNameSortLesser) + end + + local onlyUnsorted = not sortedGroups[2] and sortedGroups[1] == categories.unsorted + + for iA = 1, #sortedCategories do + local category = sortedCategories[iA] + local optionsCount = #category.sortedOptions + if optionsCount > 0 then + if not onlyUnsorted then + index = index + 1 + addOptionCategory(category, index, added) + end + for iB = 1, optionsCount do + index = index + 1 + addOption(category.sortedOptions[iB], index, added) + end + end + end]] + + widget.setData(OPTIONS_WIDGET, added) +end + + +local function initCallbacks() + widget.registerMemberCallback(GROUP_LIST_WIDGET, "selectGroup", selectGroup) +end + +function init() + --log = chat and chat.addMessage or sb.logInfo + + widget.clearListItems(GROUP_LIST_WIDGET) + initCallbacks() + parseGroups() + + script.setUpdateDelta(1) +end