Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
Merge branch 'entry'
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamesuta committed Sep 25, 2016
2 parents c84fd0c + 1a17a23 commit f93862b
Show file tree
Hide file tree
Showing 67 changed files with 2,275 additions and 1,225 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ group=com.kamesuta.mc
modid=signpic
modname=SignPicture
version_major=2
version_minor=1
version_micro=5
version_minor=2
version_micro=0.beta
version_minecraft=1.7.10
version_forge=10.13.4.1558-1.7.10
6 changes: 4 additions & 2 deletions src/main/java/com/kamesuta/mc/bnnwidget/WCommon.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import com.kamesuta.mc.bnnwidget.position.Point;

public interface WCommon {
void init(WEvent ev, Area pgp);
void onAdded();

void onInit(WEvent ev, Area pgp, Point mouse);

void draw(WEvent ev, Area pgp, Point mouse, float frame);

Expand All @@ -22,7 +24,7 @@ public interface WCommon {

void mouseReleased(WEvent ev, Area pgp, Point mouse, int button);

void onCloseRequest(final WEvent ev, final Area pgp, final Point mouse);
boolean onCloseRequest();

boolean onClosing(WEvent ev, Area pgp, Point mouse);

Expand Down
9 changes: 7 additions & 2 deletions src/main/java/com/kamesuta/mc/bnnwidget/WComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

public class WComponent extends WGui implements WCommon {
@Override
public void init(final WEvent ev, final Area pgp) {}
public void onAdded() {}

@Override
public void onInit(final WEvent ev, final Area pgp, final Point p) {}

@Override
public void draw(final WEvent ev, final Area pgp, final Point p, final float frame) {}
Expand All @@ -32,7 +35,9 @@ public void mouseDragged(final WEvent ev, final Area pgp, final Point p, final i
public void mouseReleased(final WEvent ev, final Area pgp, final Point mouse, final int button) {}

@Override
public void onCloseRequest(final WEvent ev, final Area pgp, final Point mouse) {}
public boolean onCloseRequest() {
return true;
}

@Override
public boolean onClosing(final WEvent ev, final Area pgp, final Point mouse) {
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/com/kamesuta/mc/bnnwidget/WFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ protected void sInitGui() {
}

protected void initWidget() {
final Area gp = getAbsolute();
for (final WCommon widget : this.widgets)
widget.init(this.event, gp);
widget.onAdded();
}

protected void init() {
Expand Down Expand Up @@ -198,10 +197,8 @@ protected void close() {
}

public void requestClose() {
final Area gp = getAbsolute();
final Point p = getMouseAbsolute();
for (final WCommon widget : this.widgets)
widget.onCloseRequest(this.event, gp, p);
widget.onCloseRequest();
this.closeRequest = true;
}

Expand Down
15 changes: 10 additions & 5 deletions src/main/java/com/kamesuta/mc/bnnwidget/WGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public static void drawTexturedModalRect(final float x, final float y, final flo
t.draw();
}

public static void drawTexturedModelRectFromIcon(final float x, final float y, final IIcon image, final float width, final float height)
public static void drawTexturedModalRectFromIcon(final float x, final float y, final IIcon image, final float width, final float height)
{
t.startDrawingQuads();
t.addVertexWithUV(x + 0, y + height, 0, image.getMinU(), image.getMaxV());
Expand All @@ -147,7 +147,7 @@ public static void drawTexturedModelRectFromIcon(final float x, final float y, f
t.draw();
}

public static void drawTexturedModelRect(final float x, final float y, final float u, final float v, final float width, final float height, final float divu, final float divv)
public static void drawTexturedModalRect(final float x, final float y, final float u, final float v, final float width, final float height, final float divu, final float divv)
{
final float mulu = 1.0F / divu;
final float mulv = 1.0F / divv;
Expand All @@ -159,7 +159,7 @@ public static void drawTexturedModelRect(final float x, final float y, final flo
t.draw();
}

public static void drawTexturedModelRect(final float x, final float y, final float u, final float v, final float uwidth, final float vheight, final float width, final float height, final float divu, final float divv)
public static void drawTexturedModalRect(final float x, final float y, final float u, final float v, final float uwidth, final float vheight, final float width, final float height, final float divu, final float divv)
{
final float mulu = 1.0F / divu;
final float mulv = 1.0F / divv;
Expand Down Expand Up @@ -244,6 +244,11 @@ public static void drawTexturedModalRect(final Area a, final float u, final floa
drawTexturedModalRect(a.x1(), a.y1(), u, v, a.w(), a.h());
}

public static void drawTexturedModalRect(final Area a)
{
drawTexturedModalRect(a.x1(), a.y1(), 0, 0, 1, 1, a.w(), a.h(), 1, 1);
}

/**
* Draws a textured rectangle at the stored z-value. Args: x, y, u, v, width, height
*/
Expand All @@ -259,9 +264,9 @@ public static void drawTexturedModalRect(final Area a, final Area texture)
t.draw();
}

public static void drawTexturedModelRectFromIcon(final Area a, final IIcon icon)
public static void drawTexturedModalRectFromIcon(final Area a, final IIcon icon)
{
drawTexturedModelRectFromIcon(a.x1(), a.y1(), icon, a.w(), a.h());
drawTexturedModalRectFromIcon(a.x1(), a.y1(), icon, a.w(), a.h());
}

public static void translate(final Area p) {
Expand Down
65 changes: 51 additions & 14 deletions src/main/java/com/kamesuta/mc/bnnwidget/WPanel.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.kamesuta.mc.bnnwidget;

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Iterator;
import java.util.List;

import com.kamesuta.mc.bnnwidget.position.Area;
Expand All @@ -9,6 +12,7 @@

public class WPanel extends WBase implements WContainer {
protected final ArrayList<WCommon> widgets = new ArrayList<WCommon>();
protected final Deque<WCommon> removelist = new ArrayDeque<WCommon>();

public WPanel(final R position) {
super(position);
Expand All @@ -21,23 +25,35 @@ public List<WCommon> getContainer() {

@Override
public boolean add(final WCommon widget) {
return this.widgets.add(widget);
final boolean b = this.widgets.add(widget);
widget.onAdded();
return b;
}

@Override
public boolean remove(final WCommon widget) {
return this.widgets.remove(widget);
if (widget.onCloseRequest()) {
this.widgets.remove(widget);
return true;
} else {
this.removelist.offer(widget);
return false;
}
}

@Override
public void init(final WEvent ev, final Area pgp) {
initWidget(ev, pgp);
final Area gp = getGuiPosition(pgp);
for (final WCommon widget : this.widgets)
widget.init(ev, gp);
public void onAdded() {
initWidget();
}

protected void initWidget(final WEvent ev, final Area pgp) {
protected void initWidget() {
}

@Override
public void onInit(final WEvent ev, final Area pgp, final Point p) {
final Area gp = getGuiPosition(pgp);
for (final WCommon widget : this.widgets)
widget.onInit(ev, gp, p);
}

@Override
Expand All @@ -52,6 +68,13 @@ public void update(final WEvent ev, final Area pgp, final Point p) {
final Area gp = getGuiPosition(pgp);
for (final WCommon widget : this.widgets)
widget.update(ev, gp, p);
for (final Iterator<WCommon> itr = this.removelist.iterator(); itr.hasNext();) {
final WCommon widget = itr.next();
if (widget.onClosing(ev, gp, p)) {
this.widgets.remove(widget);
itr.remove();
}
}
}

@Override
Expand Down Expand Up @@ -97,18 +120,32 @@ public void mouseReleased(final WEvent ev, final Area pgp, final Point p, final
}

@Override
public void onCloseRequest(final WEvent ev, final Area pgp, final Point p) {
final Area gp = getGuiPosition(pgp);
for (final WCommon widget : this.widgets)
widget.onCloseRequest(ev, gp, p);
public boolean onCloseRequest() {
boolean closable = true;
for (final Iterator<WCommon> itr = this.widgets.iterator(); itr.hasNext();) {
final WCommon widget = itr.next();
if (widget.onCloseRequest())
itr.remove();
else {
this.removelist.offer(widget);
closable = false;
}
}
return closable;
}

@Override
public boolean onClosing(final WEvent ev, final Area pgp, final Point p) {
final Area gp = getGuiPosition(pgp);
boolean closable = true;
for (final WCommon widget : this.widgets)
closable = closable && widget.onClosing(ev, gp, p);
for (final Iterator<WCommon> itr = this.removelist.iterator(); itr.hasNext();) {
final WCommon widget = itr.next();
if (widget.onClosing(ev, gp, p)) {
this.widgets.remove(widget);
itr.remove();
} else
closable = false;
}
return closable;
}

Expand Down
49 changes: 49 additions & 0 deletions src/main/java/com/kamesuta/mc/bnnwidget/component/FunnyButton.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.kamesuta.mc.bnnwidget.component;

import static org.lwjgl.opengl.GL11.*;

import com.kamesuta.mc.bnnwidget.WEvent;
import com.kamesuta.mc.bnnwidget.motion.Easings;
import com.kamesuta.mc.bnnwidget.motion.MCoord;
import com.kamesuta.mc.bnnwidget.position.Area;
import com.kamesuta.mc.bnnwidget.position.Point;
import com.kamesuta.mc.bnnwidget.position.R;

public class FunnyButton extends MButton {
public FunnyButton(final R position, final String text) {
super(position, text);
}

boolean hover;
MCoord m = new MCoord(0);
MCoord s = new MCoord(1);

protected void state(final boolean b) {
if (b) {
if (!this.hover) {
this.hover = true;
this.m.stop().add(Easings.easeOutElastic.move(.5f, 6f)).start();
this.s.stop().add(Easings.easeOutElastic.move(.5f, 1.1f)).start();
}
} else {
if (this.hover) {
this.hover = false;
this.m.stop().add(Easings.easeOutElastic.move(.5f, 0f)).start();
this.s.stop().add(Easings.easeOutElastic.move(.5f, 1f)).start();
}
}
}

@Override
public void draw(final WEvent ev, final Area pgp, final Point p, final float frame) {
final Area a = getGuiPosition(pgp);
glPushMatrix();
glTranslatef(a.x1()+a.w()/2, a.y1()+a.h()/2, 0);
final float c = this.s.get();
glScalef(c, c, 1f);
glRotatef(this.m.get(), 0, 0, 1);
glTranslatef(-a.x1()-a.w()/2, -a.y1()-a.h()/2, 0);
super.draw(ev, pgp, p, frame);
glPopMatrix();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,42 @@
import com.kamesuta.mc.bnnwidget.position.R;

import net.minecraft.client.gui.GuiTextField;
import net.minecraft.util.ChatAllowedCharacters;

public class MChatTextField extends WBase {
protected final GuiTextField t;

public String watermark;
protected String watermark;
protected String allowedCharacters;

public MChatTextField(final R position) {
super(position);
this.t = new GuiTextField(font(), 0, 0, 0, 0);
}

public void setWatermark(final String watermark) {
public boolean canAddChar(final char c) {
if (StringUtils.isEmpty(this.allowedCharacters))
return true;
else if (!ChatAllowedCharacters.isAllowedCharacter(c))
return true;
else
return this.allowedCharacters.indexOf(c) >= 0;
}

public MChatTextField setWatermark(final String watermark) {
this.watermark = watermark;
return this;
}

public String getWatermark() {
return this.watermark;
}

public MChatTextField setAllowedCharacters(final String s) {
this.allowedCharacters = s;
return this;
}

@Override
public void draw(final WEvent ev, final Area pgp, final Point p, final float frame) {
final Area a = getGuiPosition(pgp);
Expand Down Expand Up @@ -59,16 +76,17 @@ public void draw(final WEvent ev, final Area pgp, final Point p, final float fra
}

@Override
public void init(final WEvent ev, final Area pgp) {
final Area a = getGuiPosition(pgp);
updateArea(a);
public void onAdded() {
updateArea(new Area(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE));
}

@Override
public void mouseClicked(final WEvent ev, final Area pgp, final Point p, final int button) {
final Area a = getGuiPosition(pgp);
updateArea(a);
final boolean b = isFocused();
if (button == 1 && a.pointInside(p))
setText("");
this.t.mouseClicked((int) p.x(), (int) p.y(), button);
if (b!=isFocused()) onFocusChanged();
}
Expand All @@ -80,12 +98,14 @@ public void update(final WEvent ev, final Area pgp, final Point p) {

@Override
public void keyTyped(final WEvent ev, final Area pgp, final Point p, final char c, final int keycode) {
this.t.textboxKeyTyped(c, keycode);
if (canAddChar(c))
this.t.textboxKeyTyped(c, keycode);
}

@Override
public void onCloseRequest(final WEvent ev, final Area pgp, final Point mouse) {
public boolean onCloseRequest() {
setFocused(false);
return true;
}

protected void updateArea(final Area a) {
Expand Down
Loading

0 comments on commit f93862b

Please sign in to comment.