REMOVE: license verification and BuyGame btns/screens

This commit is contained in:
Kolyah35
2026-03-11 00:39:27 +03:00
parent 3c71139a7c
commit d25a04f154
15 changed files with 9 additions and 363 deletions

View File

@@ -96,9 +96,6 @@ public:
virtual std::string getDateString(int s) { return ""; } virtual std::string getDateString(int s) { return ""; }
//virtual void createUserInputScreen(const char* types) {} //virtual void createUserInputScreen(const char* types) {}
virtual int checkLicense() { return 0; }
virtual bool hasBuyButtonWhenInvalidLicense() { return false; }
virtual void uploadPlatformDependentData(int id, void* data) {} virtual void uploadPlatformDependentData(int id, void* data) {}
virtual BinaryBlob readAssetFile(const std::string& filename) { return BinaryBlob(); } virtual BinaryBlob readAssetFile(const std::string& filename) { return BinaryBlob(); }
virtual void _tick() {} virtual void _tick() {}
@@ -117,8 +114,6 @@ public:
virtual bool isSuperFast() = 0; virtual bool isSuperFast() = 0;
#endif #endif
virtual void buyGame() {}
virtual void openURL(const std::string& url) {} virtual void openURL(const std::string& url) {}
virtual void finish() {} virtual void finish() {}

View File

@@ -68,9 +68,6 @@ public:
_methodGetDateString(0), _methodGetDateString(0),
_methodCheckLicense(0),
_methodHasBuyButton(0),
_methodBuyGame(0),
_methodVibrate(0), _methodVibrate(0),
_methodSupportsTouchscreen(0), _methodSupportsTouchscreen(0),
_methodSetIsPowerVR(0), _methodSetIsPowerVR(0),
@@ -147,10 +144,6 @@ public:
_methodGetDateString = env->GetMethodID( _activityClass, "getDateString", "(I)Ljava/lang/String;"); _methodGetDateString = env->GetMethodID( _activityClass, "getDateString", "(I)Ljava/lang/String;");
_methodCheckLicense = env->GetMethodID( _activityClass, "checkLicense", "()I");
_methodHasBuyButton = env->GetMethodID( _activityClass, "hasBuyButtonWhenInvalidLicense", "()Z");
_methodBuyGame = env->GetMethodID( _activityClass, "buyGame", "()V");
_methodVibrate = env->GetMethodID( _activityClass, "vibrate", "(I)V"); _methodVibrate = env->GetMethodID( _activityClass, "vibrate", "(I)V");
_methodSupportsTouchscreen = env->GetMethodID( _activityClass, "supportsTouchscreen", "()Z"); _methodSupportsTouchscreen = env->GetMethodID( _activityClass, "supportsTouchscreen", "()Z");
_methodSetIsPowerVR = env->GetMethodID( _activityClass, "setIsPowerVR", "(Z)V"); _methodSetIsPowerVR = env->GetMethodID( _activityClass, "setIsPowerVR", "(Z)V");
@@ -473,36 +466,6 @@ public:
return out; return out;
} }
int checkLicense() {
if (!_isInited) return -2;
if (!_methodCheckLicense) return -2;
JVMAttacher ta(_vm);
JNIEnv* env = ta.getEnv();
return env->CallIntMethod(instance, _methodCheckLicense);
}
bool hasBuyButtonWhenInvalidLicense() {
if (!_isInited) return false;
if (!_methodHasBuyButton) return false;
JVMAttacher ta(_vm);
JNIEnv* env = ta.getEnv();
return JNI_TRUE == env->CallBooleanMethod(instance, _methodHasBuyButton);
}
void buyGame() {
if (!_isInited) return;
if (!_methodBuyGame) return;
JVMAttacher ta(_vm);
JNIEnv* env = ta.getEnv();
env->CallVoidMethod(instance, _methodBuyGame);
}
virtual void finish() { virtual void finish() {
if (!_isInited) return; if (!_isInited) return;
if (!_methodFinish) return; if (!_methodFinish) return;
@@ -644,10 +607,6 @@ private:
jmethodID _methodGetDateString; jmethodID _methodGetDateString;
jmethodID _methodCheckLicense;
jmethodID _methodHasBuyButton;
jmethodID _methodBuyGame;
jmethodID _getScreenWidth; jmethodID _getScreenWidth;
jmethodID _getScreenHeight; jmethodID _getScreenHeight;
jmethodID _methodGetPixelsPerMillimeter; jmethodID _methodGetPixelsPerMillimeter;

View File

@@ -111,21 +111,12 @@ public:
return std::string(mbstr); return std::string(mbstr);
} }
virtual int checkLicense() {
static int _z = 0;//20;
_z--;
if (_z < 0) return 0;
//if (_z < 0) return 107;
return -2;
}
virtual int getScreenWidth() { return 854; }; virtual int getScreenWidth() { return 854; };
virtual int getScreenHeight() { return 480; }; virtual int getScreenHeight() { return 480; };
virtual float getPixelsPerMillimeter(); virtual float getPixelsPerMillimeter();
virtual bool supportsTouchscreen() { return true; } virtual bool supportsTouchscreen() { return true; }
virtual bool hasBuyButtonWhenInvalidLicense() { return false; }
virtual void openURL(const std::string& url) { virtual void openURL(const std::string& url) {
#ifdef _WIN32 #ifdef _WIN32

View File

@@ -41,17 +41,6 @@ public:
std::string getDateString(int s); std::string getDateString(int s);
virtual int checkLicense() {
return 0;
static int _z = 20;
_z--;
if (_z < 0) return 0;
//if (_z < 0) return 107;
return -2;
}
virtual void buyGame();
virtual int getScreenWidth(); virtual int getScreenWidth();
virtual int getScreenHeight(); virtual int getScreenHeight();
virtual float getPixelsPerMillimeter(); virtual float getPixelsPerMillimeter();

View File

@@ -175,10 +175,6 @@ BinaryBlob AppPlatform_iOS::readAssetFile(const std::string& filename_) {
return BinaryBlob(bytes, numBytes); return BinaryBlob(bytes, numBytes);
} }
void AppPlatform_iOS::buyGame() {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=479516143&mt=8"]];
}
std::string AppPlatform_iOS::getDateString(int s) { std::string AppPlatform_iOS::getDateString(int s) {
NSDate* date = [NSDate dateWithTimeIntervalSince1970:s]; NSDate* date = [NSDate dateWithTimeIntervalSince1970:s];

View File

@@ -14,4 +14,3 @@ float AppPlatform_win32::getPixelsPerMillimeter() {
} }
bool AppPlatform_win32::supportsTouchscreen() { return true; } bool AppPlatform_win32::supportsTouchscreen() { return true; }
bool AppPlatform_win32::hasBuyButtonWhenInvalidLicense() { return true; }

View File

@@ -111,21 +111,12 @@ public:
return std::string(mbstr); return std::string(mbstr);
} }
virtual int checkLicense() {
static int _z = 0;//20;
_z--;
if (_z < 0) return 0;
//if (_z < 0) return 107;
return -2;
}
virtual int getScreenWidth(); virtual int getScreenWidth();
virtual int getScreenHeight(); virtual int getScreenHeight();
virtual float getPixelsPerMillimeter(); virtual float getPixelsPerMillimeter();
virtual bool supportsTouchscreen(); virtual bool supportsTouchscreen();
virtual bool hasBuyButtonWhenInvalidLicense();
virtual void openURL(const std::string& url) { virtual void openURL(const std::string& url) {
ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL); ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);

View File

@@ -1455,12 +1455,6 @@ LevelStorageSource* Minecraft::getLevelSource()
return storageSource; return storageSource;
} }
int Minecraft::getLicenseId() {
if (!LicenseCodes::isReady(_licenseId))
_licenseId = platform()->checkLicense();
return _licenseId;
}
void Minecraft::audioEngineOn() { void Minecraft::audioEngineOn() {
#ifndef STANDALONE_SERVER #ifndef STANDALONE_SERVER
soundEngine->enable(true); soundEngine->enable(true);

View File

@@ -109,7 +109,6 @@ public:
void onGraphicsReset(); void onGraphicsReset();
bool isLevelGenerated(); bool isLevelGenerated();
int getLicenseId();
void audioEngineOn(); void audioEngineOn();
void audioEngineOff(); void audioEngineOff();

View File

@@ -1,26 +0,0 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__BuyGameScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__BuyGameScreen_H__
#include "../Screen.h"
#include "../components/Button.h"
class BuyGameScreen: public Screen
{
public:
BuyGameScreen() {}
virtual ~BuyGameScreen() {}
void init();
void render(int xm, int ym, float a);
void buttonClicked(Button* button) {
//if (button->id == bQuit.id)
}
private:
//Button bQuit;
//Button bBuyGame;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__BuyGameScreen_H__*/

View File

@@ -1,107 +0,0 @@
#ifndef NET_MINECRAFT_CLIENT_GUI_SCREENS__InvalidLicenseScreen_H__
#define NET_MINECRAFT_CLIENT_GUI_SCREENS__InvalidLicenseScreen_H__
#include "../Screen.h"
#include "../components/Button.h"
#include "../../Minecraft.h"
#include "../../../LicenseCodes.h"
class InvalidLicenseScreen: public Screen
{
public:
InvalidLicenseScreen(int id, bool hasBuyButton)
: _id(id),
_hasBuyButton(hasBuyButton),
_baseY(0),
bOk(0),
bBuy(0)
{
}
virtual ~InvalidLicenseScreen() {
delete bOk;
delete bBuy;
}
void init() {
if (minecraft->useTouchscreen()) {
bOk = new Touch::TButton(1, "Ok");
bBuy = new Touch::TButton(2, "Buy");
} else {
bOk = new Button(1, "Ok");
bBuy = new Button(2, "Buy");
}
if (_hasBuyButton)
bOk->msg = "Quit";
if (!LicenseCodes::isOk(_id)) {
char buf[20] = {0};
sprintf(buf, "%d", _id);
desc1 = "License verification failed (error ";
desc1 += buf;
desc1 += ")";
desc2 = "Try again later.";
hint = "You need to be connected to the internet\n";
hint += "once while you start the game.";
}
buttons.push_back(bOk);
tabButtons.push_back(bOk);
if (_hasBuyButton) {
buttons.push_back(bBuy);
tabButtons.push_back(bBuy);
}
}
void setupPositions() {
_baseY = height/5 + 6;
//if (_hasBuyButton)
_baseY -= 24;
bOk->width = bBuy->width = 200;
bOk->x = bBuy->x = (width - bOk->width) / 2;
bBuy->y = _baseY + 84;
bOk->y = bBuy->y + bBuy->height + 4;
if (!_hasBuyButton)
bOk->y -= 24;
}
void tick() {}
//void keyPressed(int eventKey) {}
void render(int xm, int ym, float a) {
renderDirtBackground(0);
drawCenteredString(minecraft->font, desc1, width/2, _baseY, 0xffffff);
drawCenteredString(minecraft->font, desc2, width/2, _baseY + 24, 0xffffff);
drawCenteredString(minecraft->font, hint, width/2, _baseY + 60, 0xffffff);
Screen::render(xm, ym, a);
}
void buttonClicked(Button* button) {
if (button->id == bOk->id) {
minecraft->quit();
}
if (button->id == bBuy->id) {
minecraft->platform()->buyGame();
}
};
private:
int _id;
std::string desc1;
std::string desc2;
std::string hint;
Button* bOk;
Button* bBuy;
bool _hasBuyButton;
int _baseY;
};
#endif /*NET_MINECRAFT_CLIENT_GUI_SCREENS__InvalidLicenseScreen_H__*/

View File

@@ -5,9 +5,7 @@
#include "JoinGameScreen.h" #include "JoinGameScreen.h"
#include "OptionsScreen.h" #include "OptionsScreen.h"
#include "PauseScreen.h" #include "PauseScreen.h"
#include "InvalidLicenseScreen.h"
#include "PrerenderTilesScreen.h" // test button #include "PrerenderTilesScreen.h" // test button
//#include "BuyGameScreen.h"
#include "../../../util/Mth.h" #include "../../../util/Mth.h"
@@ -27,9 +25,7 @@
StartMenuScreen::StartMenuScreen() StartMenuScreen::StartMenuScreen()
: bHost( 2, 0, 0, 160, 24, "Start Game"), : bHost( 2, 0, 0, 160, 24, "Start Game"),
bJoin( 3, 0, 0, 160, 24, "Join Game"), bJoin( 3, 0, 0, 160, 24, "Join Game"),
bOptions( 4, 0, 0, 78, 22, "Options"), bOptions( 4, 0, 0, 78, 22, "Options")
bBuy( 5, 0, 0, 78, 22, "Buy"),
bTest( 999, 0, 0, 78, 22, "Create")
{ {
} }
@@ -39,6 +35,9 @@ StartMenuScreen::~StartMenuScreen()
void StartMenuScreen::init() void StartMenuScreen::init()
{ {
bJoin.active = bHost.active = bOptions.active = true;
if (minecraft->options.username.empty()) { if (minecraft->options.username.empty()) {
return; // tick() will redirect to UsernameScreen return; // tick() will redirect to UsernameScreen
} }
@@ -94,14 +93,12 @@ void StartMenuScreen::setupPositions() {
#endif #endif
bOptions.y = yBase + 28 + 2; bOptions.y = yBase + 28 + 2;
bTest.y = bBuy.y = bOptions.y;
//#endif //#endif
// Center buttons // Center buttons
bHost.x = (width - bHost.width) / 2; bHost.x = (width - bHost.width) / 2;
bJoin.x = (width - bJoin.width) / 2; bJoin.x = (width - bJoin.width) / 2;
bOptions.x = (width - bJoin.width) / 2; bOptions.x = (width - bJoin.width) / 2;
bTest.x = bBuy.x = bOptions.x + bOptions.width + 4;
copyrightPosX = width - minecraft->font->width(copyright) - 1; copyrightPosX = width - minecraft->font->width(copyright) - 1;
versionPosX = (width - minecraft->font->width(version)) / 2;// - minecraft->font->width(version) - 2; versionPosX = (width - minecraft->font->width(version)) / 2;// - minecraft->font->width(version) - 2;
@@ -112,7 +109,6 @@ void StartMenuScreen::tick() {
minecraft->setScreen(new UsernameScreen()); minecraft->setScreen(new UsernameScreen());
return; return;
} }
_updateLicense();
} }
void StartMenuScreen::buttonClicked(Button* button) { void StartMenuScreen::buttonClicked(Button* button) {
@@ -134,16 +130,6 @@ void StartMenuScreen::buttonClicked(Button* button) {
{ {
minecraft->setScreen(new OptionsScreen()); minecraft->setScreen(new OptionsScreen());
} }
if (button->id == bTest.id)
{
//minecraft->setScreen(new PauseScreen());
//minecraft->setScreen(new PrerenderTilesScreen());
}
if (button->id == bBuy.id)
{
minecraft->platform()->buyGame();
//minecraft->setScreen(new BuyGameScreen());
}
} }
bool StartMenuScreen::isInGameScreen() { return false; } bool StartMenuScreen::isInGameScreen() { return false; }
@@ -202,23 +188,6 @@ void StartMenuScreen::render( int xm, int ym, float a )
} }
} }
void StartMenuScreen::_updateLicense()
{
int id = minecraft->getLicenseId();
if (LicenseCodes::isReady(id))
{
if (LicenseCodes::isOk(id))
bJoin.active = bHost.active = bOptions.active = true;
else
{
bool hasBuyButton = minecraft->platform()->hasBuyButtonWhenInvalidLicense();
minecraft->setScreen(new InvalidLicenseScreen(id, hasBuyButton));
}
} else {
bJoin.active = bHost.active = bOptions.active = false;
}
}
void StartMenuScreen::mouseClicked(int x, int y, int buttonNum) { void StartMenuScreen::mouseClicked(int x, int y, int buttonNum) {
const int logoX = 2; const int logoX = 2;
const int logoW = 8 + 2 + font->width("Kolyah35/minecraft-pe-0.6.1"); const int logoW = 8 + 2 + font->width("Kolyah35/minecraft-pe-0.6.1");

View File

@@ -21,13 +21,10 @@ public:
bool handleBackEvent(bool isDown); bool handleBackEvent(bool isDown);
bool isInGameScreen(); bool isInGameScreen();
private: private:
void _updateLicense();
Button bHost; Button bHost;
Button bJoin; Button bJoin;
Button bOptions; Button bOptions;
Button bTest;
Button bBuy;
std::string copyright; std::string copyright;
int copyrightPosX; int copyrightPosX;

View File

@@ -2,8 +2,6 @@
#include "../ProgressScreen.h" #include "../ProgressScreen.h"
#include "../OptionsScreen.h" #include "../OptionsScreen.h"
#include "../PauseScreen.h" #include "../PauseScreen.h"
#include "../InvalidLicenseScreen.h"
//#include "BuyGameScreen.h"
#include "../../Font.h" #include "../../Font.h"
#include "../../components/SmallButton.h" #include "../../components/SmallButton.h"
@@ -22,62 +20,6 @@
#include "../DialogDefinitions.h" #include "../DialogDefinitions.h"
#include "../SimpleChooseLevelScreen.h" #include "../SimpleChooseLevelScreen.h"
//
// Buy Button implementation
//
BuyButton::BuyButton(int id)
: super(id, "")
{
ImageDef def;
// Setup the source rectangle
def.setSrc(IntRectangle(64, 182, 190, 55));
def.width = 75;//rc.w / 3;
def.height = 75 * (55.0f / 190.0f);//rc.h / 3;
def.name = "gui/gui.png";
setImageDef(def, true);
}
void BuyButton::render(Minecraft* minecraft, int xm, int ym) {
glColor4f2(1, 1, 1, 1);
bool hovered = active && (minecraft->useTouchscreen()? (xm >= x && ym >= y && xm < x + width && ym < y + height) : false);
renderBg(minecraft, xm, ym);
TextureId texId = (_imageDef.name.length() > 0)? minecraft->textures->loadAndBindTexture(_imageDef.name) : Textures::InvalidId;
if ( Textures::isTextureIdValid(texId) ) {
const ImageDef& d = _imageDef;
Tesselator& t = Tesselator::instance;
t.begin();
if (!active) t.color(0xff808080);
else if (hovered||selected) t.color(0xffcccccc);
//else t.color(0xffe0e0e0);
else t.color(0xffffffff);
float hx = ((float) d.width) * 0.5f;
float hy = ((float) d.height) * 0.5f;
const float cx = ((float)x+d.x) + hx;
const float cy = ((float)y+d.y) + hy;
if (hovered) {
hx *= 0.95f;
hy *= 0.95f;
}
const TextureData* td = minecraft->textures->getTemporaryTextureData(texId);
const IntRectangle* src = _imageDef.getSrc();
if (td != NULL && src != NULL) {
float u0 = (src->x) / (float)td->w;
float u1 = (src->x+src->w) / (float)td->w;
float v0 = (src->y) / (float)td->h;
float v1 = (src->y+src->h) / (float)td->h;
t.vertexUV(cx-hx, cy-hy, blitOffset, u0, v0);
t.vertexUV(cx-hx, cy+hy, blitOffset, u0, v1);
t.vertexUV(cx+hx, cy+hy, blitOffset, u1, v1);
t.vertexUV(cx+hx, cy-hy, blitOffset, u1, v0);
}
t.draw();
}
}
namespace Touch { namespace Touch {
// //
@@ -88,8 +30,7 @@ namespace Touch {
StartMenuScreen::StartMenuScreen() StartMenuScreen::StartMenuScreen()
: bHost( 2, "Start Game"), : bHost( 2, "Start Game"),
bJoin( 3, "Join Game"), bJoin( 3, "Join Game"),
bOptions( 4, "Options"), bOptions( 4, "Options")
bBuy( 5)
{ {
ImageDef def; ImageDef def;
bJoin.width = 75; bJoin.width = 75;
@@ -148,7 +89,7 @@ void StartMenuScreen::init()
version = versionString + " (Demo)"; version = versionString + " (Demo)";
#endif #endif
bJoin.active = bHost.active = bOptions.active = false; bJoin.active = bHost.active = bOptions.active = true;
} }
void StartMenuScreen::setupPositions() { void StartMenuScreen::setupPositions() {
@@ -166,20 +107,11 @@ void StartMenuScreen::setupPositions() {
bJoin.x = 0*buttonWidth + (int)(1*spacing); bJoin.x = 0*buttonWidth + (int)(1*spacing);
bHost.x = 1*buttonWidth + (int)(2*spacing); bHost.x = 1*buttonWidth + (int)(2*spacing);
bOptions.x = 2*buttonWidth + (int)(3*spacing); bOptions.x = 2*buttonWidth + (int)(3*spacing);
//bBuy.y = bOptions.y - bBuy.h - 6;
//bBuy.x = bOptions.x + bOptions.w - bBuy.w;
bBuy.y = height - bBuy.height - 3;
bBuy.x = (width - bBuy.width) / 2;
copyrightPosX = width - minecraft->font->width(copyright) - 1; copyrightPosX = width - minecraft->font->width(copyright) - 1;
versionPosX = (width - minecraft->font->width(version)) / 2;// - minecraft->font->width(version) - 2; versionPosX = (width - minecraft->font->width(version)) / 2;// - minecraft->font->width(version) - 2;
} }
void StartMenuScreen::tick() {
_updateLicense();
}
void StartMenuScreen::buttonClicked(::Button* button) { void StartMenuScreen::buttonClicked(::Button* button) {
if (button->id == bHost.id) if (button->id == bHost.id)
@@ -203,11 +135,6 @@ void StartMenuScreen::buttonClicked(::Button* button) {
{ {
minecraft->setScreen(new OptionsScreen()); minecraft->setScreen(new OptionsScreen());
} }
if (button->id == bBuy.id)
{
minecraft->platform()->buyGame();
//minecraft->setScreen(new BuyGameScreen());
}
} }
bool StartMenuScreen::isInGameScreen() { return false; } bool StartMenuScreen::isInGameScreen() { return false; }
@@ -256,22 +183,6 @@ void StartMenuScreen::render( int xm, int ym, float a )
glDisable2(GL_BLEND); glDisable2(GL_BLEND);
} }
void StartMenuScreen::_updateLicense()
{
int id = minecraft->getLicenseId();
if (LicenseCodes::isReady(id))
{
if (LicenseCodes::isOk(id))
bJoin.active = bHost.active = bOptions.active = true;
else
{
bool hasBuyButton = minecraft->platform()->hasBuyButtonWhenInvalidLicense();
minecraft->setScreen(new InvalidLicenseScreen(id, hasBuyButton));
}
} else {
bJoin.active = bHost.active = bOptions.active = false;
}
}
void StartMenuScreen::mouseClicked(int x, int y, int buttonNum) { void StartMenuScreen::mouseClicked(int x, int y, int buttonNum) {
const int logoX = 2; const int logoX = 2;

View File

@@ -5,14 +5,6 @@
#include "../../components/LargeImageButton.h" #include "../../components/LargeImageButton.h"
#include "../../components/TextBox.h" #include "../../components/TextBox.h"
class BuyButton: public ImageButton {
typedef ImageButton super;
public:
BuyButton(int id);
void render(Minecraft* minecraft, int xm, int ym);
};
namespace Touch { namespace Touch {
class StartMenuScreen: public Screen class StartMenuScreen: public Screen
@@ -24,7 +16,6 @@ public:
void init(); void init();
void setupPositions(); void setupPositions();
void tick();
void render(int xm, int ym, float a); void render(int xm, int ym, float a);
void buttonClicked(Button* button); void buttonClicked(Button* button);
@@ -32,12 +23,10 @@ public:
bool handleBackEvent(bool isDown); bool handleBackEvent(bool isDown);
bool isInGameScreen(); bool isInGameScreen();
private: private:
void _updateLicense();
LargeImageButton bHost; LargeImageButton bHost;
LargeImageButton bJoin; LargeImageButton bJoin;
LargeImageButton bOptions; LargeImageButton bOptions;
BuyButton bBuy;
std::string copyright; std::string copyright;
int copyrightPosX; int copyrightPosX;