aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/SignRenderer.cpp
blob: 3f0b21757884612b6a7f607f610983b21d84e75a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include "stdafx.h"
#include "SignRenderer.h"
#include "SignModel.h"
#include "ModelPart.h"
#include "..\Minecraft.World\net.minecraft.world.level.tile.entity.h"
#include "..\Minecraft.World\net.minecraft.world.level.tile.h"
#include "..\Minecraft.World\Entity.h"
#include "..\Minecraft.World\Level.h"

ResourceLocation SignRenderer::SIGN_LOCATION = ResourceLocation(TN_ITEM_SIGN);

SignRenderer::SignRenderer()
{
	signModel = new SignModel();
}

void SignRenderer::render(shared_ptr<TileEntity> _sign, double x, double y, double z, float a, bool setColor, float alpha, bool useCompiled)
{
	// 4J - dynamic cast required because we aren't using templates/generics in our version
	shared_ptr<SignTileEntity> sign = dynamic_pointer_cast<SignTileEntity>(_sign);

    Tile *tile = sign->getTile();

    glPushMatrix();
    float size = 16 / 24.0f;
    if (tile == Tile::sign)
	{
        glTranslatef(static_cast<float>(x) + 0.5f, static_cast<float>(y) + 0.75f * size, static_cast<float>(z) + 0.5f);
        float rot = sign->getData() * 360 / 16.0f;
        glRotatef(-rot, 0, 1, 0);
        signModel->cube2->visible = true;
    }
	else
	{
        int face = sign->getData();
        float rot = 0;

        if (face == 2) rot = 180;
        if (face == 4) rot = 90;
        if (face == 5) rot = -90;

        glTranslatef(static_cast<float>(x) + 0.5f, static_cast<float>(y) + 0.75f * size, static_cast<float>(z) + 0.5f);
        glRotatef(-rot, 0, 1, 0);
        glTranslatef(0, -5 / 16.0f, -7 / 16.0f);

        signModel->cube2->visible = false;
    }

    bindTexture(&SIGN_LOCATION);	// 4J was L"/item/sign.png"

    glPushMatrix();
    glScalef(size, -size, -size);
    signModel->render(true);
    glPopMatrix();
    Font *font = getFont();

    float s = 1 / 60.0f * size;
    glTranslatef(0, 0.5f * size, 0.07f * size);
    glScalef(s, -s, s);
    glNormal3f(0, 0, -1 * s);
    glDepthMask(false);

	int col = Minecraft::GetInstance()->getColourTable()->getColor(eMinecraftColour_Sign_Text);
	wstring msg;
	// need to send the new data
	// Get the current language setting from the console
	DWORD dwLanguage = XGetLanguage( );

    for (int i = 0; i < MAX_SIGN_LINES; i++)		// 4J - was sign.messages.length
	{
		if(sign->IsVerified())
		{
			if(sign->IsCensored())
			{
				switch(dwLanguage)
				{
				case XC_LANGUAGE_KOREAN:	
				case XC_LANGUAGE_JAPANESE:
				case XC_LANGUAGE_TCHINESE:
					msg = L"Censored";// In-game font, so English only 
					break;
				default:
					msg = app.GetString(IDS_STRINGVERIFY_CENSORED);
					break;
				}
			}
			else
			{
				msg = sign->GetMessage(i);
			}
		}
		else
		{
			switch(dwLanguage)
			{
			case XC_LANGUAGE_KOREAN:	
			case XC_LANGUAGE_JAPANESE:
			case XC_LANGUAGE_TCHINESE:
				msg = L"Awaiting Approval";// In-game font, so English only 
				break;
			default:
				msg = app.GetString(IDS_STRINGVERIFY_AWAITING_APPROVAL);
				break;
			}
		}		

        if (i == sign->GetSelectedLine())
		{
            msg = L"> " + msg + L" <";
            font->draw(msg, -font->width(msg) / 2, i * 10 - (MAX_SIGN_LINES) * 5, col);		// 4J - (MAX_SIGN_LINES) was sign.messages.length
        }
		else
		{
            font->draw(msg, -font->width(msg) / 2, i * 10 - (MAX_SIGN_LINES) * 5, col);		// 4J - (MAX_SIGN_LINES) was sign.messages.length
        }
    }
    glDepthMask(true);
    glColor4f(1, 1, 1, 1);
    glPopMatrix();

}