|
3 | 3 | import com.cleanroommc.modularui.api.ITheme; |
4 | 4 | import com.cleanroommc.modularui.api.drawable.IDrawable; |
5 | 5 | import com.cleanroommc.modularui.api.drawable.IKey; |
| 6 | +import com.cleanroommc.modularui.api.drawable.ITextLine; |
6 | 7 | import com.cleanroommc.modularui.api.value.IBoolValue; |
7 | 8 | import com.cleanroommc.modularui.api.value.IEnumValue; |
8 | 9 | import com.cleanroommc.modularui.api.value.IIntValue; |
9 | 10 | import com.cleanroommc.modularui.api.widget.Interactable; |
10 | 11 | import com.cleanroommc.modularui.drawable.UITexture; |
11 | 12 | import com.cleanroommc.modularui.screen.RichTooltip; |
12 | 13 | import com.cleanroommc.modularui.theme.WidgetTheme; |
| 14 | +import com.cleanroommc.modularui.utils.Alignment; |
13 | 15 | import com.cleanroommc.modularui.value.IntValue; |
14 | 16 | import com.cleanroommc.modularui.value.sync.SyncHandler; |
15 | 17 | import com.cleanroommc.modularui.widget.Widget; |
@@ -219,6 +221,217 @@ protected W addTooltip(int state, String tooltip) { |
219 | 221 | return addTooltip(state, IKey.str(tooltip)); |
220 | 222 | } |
221 | 223 |
|
| 224 | + /** |
| 225 | + * Adds a tooltip element to all states. |
| 226 | + * |
| 227 | + * @param s element |
| 228 | + * @return this |
| 229 | + */ |
| 230 | + @Override |
| 231 | + public W addTooltipElement(String s) { |
| 232 | + for (RichTooltip tooltip : this.stateTooltip) { |
| 233 | + tooltip.add(s); |
| 234 | + } |
| 235 | + return getThis(); |
| 236 | + } |
| 237 | + |
| 238 | + /** |
| 239 | + * Adds tooltip drawables as lines to all states. |
| 240 | + * |
| 241 | + * @param lines drawables |
| 242 | + * @return this |
| 243 | + */ |
| 244 | + @Override |
| 245 | + public W addTooltipDrawableLines(Iterable<IDrawable> lines) { |
| 246 | + for (RichTooltip tooltip : this.stateTooltip) { |
| 247 | + tooltip.addDrawableLines(lines); |
| 248 | + } |
| 249 | + return getThis(); |
| 250 | + } |
| 251 | + |
| 252 | + /** |
| 253 | + * Adds a tooltip element to all states. |
| 254 | + * |
| 255 | + * @param drawable element |
| 256 | + * @return this |
| 257 | + */ |
| 258 | + @Override |
| 259 | + public W addTooltipElement(IDrawable drawable) { |
| 260 | + for (RichTooltip tooltip : this.stateTooltip) { |
| 261 | + tooltip.add(drawable); |
| 262 | + } |
| 263 | + return getThis(); |
| 264 | + } |
| 265 | + |
| 266 | + /** |
| 267 | + * Adds a tooltip line to all states. |
| 268 | + * |
| 269 | + * @param line tooltip line |
| 270 | + * @return this |
| 271 | + */ |
| 272 | + @Override |
| 273 | + public W addTooltipLine(ITextLine line) { |
| 274 | + for (RichTooltip tooltip : this.stateTooltip) { |
| 275 | + tooltip.addLine(line); |
| 276 | + } |
| 277 | + return getThis(); |
| 278 | + } |
| 279 | + |
| 280 | + /** |
| 281 | + * Adds a tooltip line to all states. |
| 282 | + * |
| 283 | + * @param drawable tooltip line |
| 284 | + * @return this |
| 285 | + */ |
| 286 | + @Override |
| 287 | + public W addTooltipLine(IDrawable drawable) { |
| 288 | + for (RichTooltip tooltip : this.stateTooltip) { |
| 289 | + tooltip.addLine(drawable); |
| 290 | + } |
| 291 | + return getThis(); |
| 292 | + } |
| 293 | + |
| 294 | + /** |
| 295 | + * Adds tooltip lines to all states. |
| 296 | + * |
| 297 | + * @param lines tooltip lines |
| 298 | + * @return this |
| 299 | + */ |
| 300 | + @Override |
| 301 | + public W addTooltipStringLines(Iterable<String> lines) { |
| 302 | + for (RichTooltip tooltip : this.stateTooltip) { |
| 303 | + tooltip.addStringLines(lines); |
| 304 | + } |
| 305 | + return getThis(); |
| 306 | + } |
| 307 | + |
| 308 | + /** |
| 309 | + * Applies a function to the tooltip of all states once. |
| 310 | + * |
| 311 | + * @param tooltipConsumer tooltip function |
| 312 | + * @return this |
| 313 | + */ |
| 314 | + @Override |
| 315 | + public W tooltipStatic(Consumer<RichTooltip> tooltipConsumer) { |
| 316 | + for (RichTooltip tooltip : this.stateTooltip) { |
| 317 | + tooltipConsumer.accept(tooltip); |
| 318 | + } |
| 319 | + return getThis(); |
| 320 | + } |
| 321 | + |
| 322 | + /** |
| 323 | + * Applies a function to the tooltip of all states every time the tooltip needs to update. |
| 324 | + * |
| 325 | + * @param tooltipBuilder tooltip function |
| 326 | + * @return this |
| 327 | + */ |
| 328 | + @Override |
| 329 | + public W tooltipDynamic(Consumer<RichTooltip> tooltipBuilder) { |
| 330 | + for (RichTooltip tooltip : this.stateTooltip) { |
| 331 | + tooltip.tooltipBuilder(tooltipBuilder); |
| 332 | + } |
| 333 | + return getThis(); |
| 334 | + } |
| 335 | + |
| 336 | + /** |
| 337 | + * Sets the tooltip alignment of all states. |
| 338 | + * |
| 339 | + * @param alignment alignment |
| 340 | + * @return this |
| 341 | + */ |
| 342 | + @Override |
| 343 | + public W tooltipAlignment(Alignment alignment) { |
| 344 | + for (RichTooltip tooltip : this.stateTooltip) { |
| 345 | + tooltip.alignment(alignment); |
| 346 | + } |
| 347 | + return getThis(); |
| 348 | + } |
| 349 | + |
| 350 | + /** |
| 351 | + * Sets the tooltip position of all states. |
| 352 | + * |
| 353 | + * @param pos tooltip pos |
| 354 | + * @return this |
| 355 | + */ |
| 356 | + @Override |
| 357 | + public W tooltipPos(RichTooltip.Pos pos) { |
| 358 | + for (RichTooltip tooltip : this.stateTooltip) { |
| 359 | + tooltip.pos(pos); |
| 360 | + } |
| 361 | + return getThis(); |
| 362 | + } |
| 363 | + |
| 364 | + /** |
| 365 | + * Sets the tooltip position of all states. |
| 366 | + * |
| 367 | + * @param x x |
| 368 | + * @param y y |
| 369 | + * @return this |
| 370 | + */ |
| 371 | + @Override |
| 372 | + public W tooltipPos(int x, int y) { |
| 373 | + for (RichTooltip tooltip : this.stateTooltip) { |
| 374 | + tooltip.pos(x, y); |
| 375 | + } |
| 376 | + return getThis(); |
| 377 | + } |
| 378 | + |
| 379 | + /** |
| 380 | + * Sets the tooltip scale of all states. |
| 381 | + * |
| 382 | + * @param scale tooltip scale |
| 383 | + * @return this |
| 384 | + */ |
| 385 | + @Override |
| 386 | + public W tooltipScale(float scale) { |
| 387 | + for (RichTooltip tooltip : this.stateTooltip) { |
| 388 | + tooltip.scale(scale); |
| 389 | + } |
| 390 | + return getThis(); |
| 391 | + } |
| 392 | + |
| 393 | + /** |
| 394 | + * Sets the tooltip text color of all states. |
| 395 | + * |
| 396 | + * @param textColor tooltip text color |
| 397 | + * @return this |
| 398 | + */ |
| 399 | + @Override |
| 400 | + public W tooltipTextColor(int textColor) { |
| 401 | + for (RichTooltip tooltip : this.stateTooltip) { |
| 402 | + tooltip.textColor(textColor); |
| 403 | + } |
| 404 | + return getThis(); |
| 405 | + } |
| 406 | + |
| 407 | + /** |
| 408 | + * Sets the tooltip text shadow of all states. |
| 409 | + * |
| 410 | + * @param textShadow tooltip pos |
| 411 | + * @return this |
| 412 | + */ |
| 413 | + @Override |
| 414 | + public W tooltipTextShadow(boolean textShadow) { |
| 415 | + for (RichTooltip tooltip : this.stateTooltip) { |
| 416 | + tooltip.textShadow(textShadow); |
| 417 | + } |
| 418 | + return getThis(); |
| 419 | + } |
| 420 | + |
| 421 | + /** |
| 422 | + * Sets the tooltip show up timer of all states. |
| 423 | + * |
| 424 | + * @param showUpTimer tooltip show up timer |
| 425 | + * @return this |
| 426 | + */ |
| 427 | + @Override |
| 428 | + public W tooltipShowUpTimer(int showUpTimer) { |
| 429 | + for (RichTooltip tooltip : this.stateTooltip) { |
| 430 | + tooltip.showUpTimer(showUpTimer); |
| 431 | + } |
| 432 | + return getThis(); |
| 433 | + } |
| 434 | + |
222 | 435 | protected W stateCount(int stateCount) { |
223 | 436 | this.stateCount = stateCount; |
224 | 437 | // adjust tooltip buffer size |
|
0 commit comments