This commit is contained in:
watrabi
2025-10-28 14:05:46 -04:00
parent 977f1ff4b8
commit c93494f795
452 changed files with 47860 additions and 152 deletions
+199
View File
@@ -0,0 +1,199 @@
/* Copyright 2003-2006 ROBLOX Corporation, All Rights Reserved */
#pragma once
#include "Gui/Gui.h"
#include "Util/RunStateOwner.h"
#include "V8DataModel/ChatService.h"
#include "Util/UDim.h"
namespace RBX {
class SafeChat;
class GuiObject;
class BillboardGui;
class ModelInstance;
namespace Network {
class Player;
class Players;
class ChatMessage;
}
class ChatLine {
protected:
static float ComputeBubbleLifetime(const std::string& msg, bool isSelf);
public:
static const char* ELIPSES;
static const int CchMaxChatMessageLength; // max chat message length, including null terminator and elipses.
enum BubbleColor
{
WHITE,
BLUE,
GREEN,
RED,
};
enum ChatType
{
PLAYER_CHAT,
PLAYER_TEAM_CHAT,
PLAYER_WHISPER_CHAT,
GAME_MESSAGE,
PLAYER_GAME_CHAT,
BOT_CHAT,
};
std::string message;
const BubbleColor bubbleColor;
const ChatType chatType;
float startTime;
float bubbleDieDelay;
bool isLocalPlayer;
boost::weak_ptr<Instance> origin;
const Instance* getOrigin() const { return origin.lock().get(); }
ChatLine(ChatType chatType, const std::string& message, float startTime, BubbleColor bubbleColor, bool isLocalPlayer);
virtual ~ChatLine() {}
bool isPlayerChat() const
{
switch(chatType)
{
case PLAYER_CHAT:
case PLAYER_TEAM_CHAT:
case PLAYER_WHISPER_CHAT:
return true;
default:
return false;
}
}
};
class PlayerChatLine : public ChatLine {
public:
static const char* ROBLOXNAME;
Color3 userColor;
std::string user;
float historyDieDelay;
const ModelInstance* getCharacter() const;
PlayerChatLine(ChatType chatType, boost::shared_ptr<Network::Player> player, const std::string& message, float startTime, bool isLocalPlayer);
};
class GameChatLine: public ChatLine
{
public:
GameChatLine(boost::shared_ptr<Instance> origin, const std::string& message, float startTime, bool isLocalPlayer, BubbleColor bubbleColor);
};
struct CharacterChats
{
CharacterChats()
: isVisible(false)
, isMoving(false)
{}
std::deque<boost::shared_ptr<ChatLine> > fifo;
bool isVisible;
bool isMoving;
weak_ptr<BillboardGui> billboardGui;
};
class ChatOutput
: public GuiItem
{
private:
static const int kMaxTextSize = 16;
static const int kMaxCharsInLine = 20;
void createBillboardGuiHelper(Instance* instance, bool character);
void renderBubbleImposters(Adorn* adorn, weak_ptr<const Instance> owner, weak_ptr<PartInstance> head);
void renderBubbles(Adorn* adorn, weak_ptr<const Instance> owner, weak_ptr<PartInstance> head, bool playerAndGameChat,
Vector3 extentsOffset, Vector3 studsOffset);
typedef GuiItem Super;
static const int MaxChatBubblesPerPlayer;
static const int MaxChatLinesPerBubble;
RBX::Network::Players* players;
std::map<ChatLine::BubbleColor, shared_ptr<GuiObject> > chatBubble;
std::map<ChatLine::BubbleColor, shared_ptr<GuiObject> > chatBubbleWithTail;
std::map<ChatLine::BubbleColor, shared_ptr<GuiObject> > scalingChatBubbleWithTail;
struct ScalingInfo
{
Vector2 scalingCutoff;
UDim2 fixedPosition;
UDim2 fixedSize;
UDim2 scalingPosition;
UDim2 scalingSize;
UDim2 getPosition(Vector2 size)
{
return UDim2(size.x < scalingCutoff.x ? scalingPosition.x : fixedPosition.x,
size.y < scalingCutoff.y ? scalingPosition.y : fixedPosition.y);
}
UDim2 getSize(Vector2 size)
{
return UDim2(size.x < scalingCutoff.x ? scalingSize.x : fixedSize.x,
size.y < scalingCutoff.y ? scalingSize.y : fixedSize.y);
}
ScalingInfo(Vector2 scalingCutoff, UDim2 fixedPosition, UDim2 fixedSize, UDim2 scalingPosition, UDim2 scalingSize)
:scalingCutoff(scalingCutoff)
,fixedPosition(fixedPosition)
,fixedSize(fixedSize)
,scalingPosition(scalingPosition)
,scalingSize(scalingSize)
{}
ScalingInfo()
{}
};
std::map<ChatLine::BubbleColor, ScalingInfo> scalingInfo;
std::map<ChatLine::BubbleColor, shared_ptr<GuiObject> > chatPlaceholder;
std::deque<boost::shared_ptr<ChatLine> > fifo;
typedef std::map<const Instance*, CharacterChats> CharacterChatMap;
CharacterChatMap characterSortedMsg;
float time;
void acceleratedBubbleDecay(ChatLine* line, float wallStep, bool isMoving, bool isVisible);
void removeOldest();
bool removeExpired();
bool bubbleChatEnabled();
std::string SanitizeChatLine(const std::string& msg); // truncate and make safe.
// Instance
/*override*/ void onServiceProvider(ServiceProvider* oldProvider, ServiceProvider* newProvider);
// Listener
rbx::signals::scoped_connection heartbeatConnection;
rbx::signals::scoped_connection playerChatMessageConnection;
rbx::signals::scoped_connection gameChatMessageConnection;
void onHeartbeat(const Heartbeat& heartbeat);
void onPlayerChatMessage(const Network::ChatMessage& event);
void onGameChatMessage(boost::shared_ptr<Instance> origin, const std::string& message, ChatService::ChatColor color);
// GuiItem
/*override*/ void render2d(Adorn* adorn);
/*override*/ void render2d_bubbleStyle(Adorn* adorn, bool playerBubbleChat);
public:
ChatOutput();
~ChatOutput();
};
} // namespace
+59
View File
@@ -0,0 +1,59 @@
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
#pragma once
#include "Gui/GuiDraw.h"
#include "GfxBase/Adorn.h"
namespace RBX {
class UnifiedImageWidget : public UnifiedWidget
{
protected:
GuiDrawImage guiImageDraw;
std::string imageName;
unsigned imageState;
public:
UnifiedImageWidget(const std::string& imageName, int imageState)
: imageName(imageName)
, imageState(imageState)
{
}
Gui::WidgetState getWidgetState() const;
/*override*/ void render2dMe(Adorn* adorn);
/*override*/ void setSize(const Vector2& _size) {guiImageDraw.setImageSize(_size);}
/*override*/ Vector2 getSize(Canvas canvas) const {return guiImageDraw.getImageSize();}
};
class ChatButton : public UnifiedImageWidget
{
private:
/*override*/ bool isVisible() const;
public:
ChatButton(const std::string& imageName, unsigned imageState)
: UnifiedImageWidget(imageName, imageState)
{
}
};
class ChatWidget : public UnifiedWidget
{
private:
typedef UnifiedWidget Super;
std::string findMenuString(GuiItem* item);
std::string code;
// Unified Widget
/*override*/ void onMenuStateChanged();
/*override*/ GuiResponse process(const shared_ptr<InputObject>& event);
public:
ChatWidget(const std::string& text, std::string code);
};
} // namespace
+27
View File
@@ -0,0 +1,27 @@
#pragma once
#include "Gui/GUI.h"
namespace RBX {
class EquationDisplay : public TextDisplay {
private:
std::string equation;
protected:
// TextDisplay
std::string getLabel() const;
public:
EquationDisplay(
const std::string& title,
const std::string& equation);
EquationDisplay(
const std::string& title,
const std::string& label,
const std::string& equation);
/*override*/ void render2d(Adorn* adorn);
};
} // namespace
+268
View File
@@ -0,0 +1,268 @@
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
#pragma once
#include "V8DataModel/InputObject.h"
#include "Gui/GuiEvent.h"
#include "Gui/Layout.h"
#include "V8Tree/Instance.h"
#include "GfxBase/Type.h"
#include "GfxBase/Adorn.h"
namespace RBX {
extern const char* const sGuiItem;
class GuiItem : public DescribedNonCreatable<GuiItem, Instance, sGuiItem>
{
private:
typedef Instance Super;
shared_ptr<GuiItem> focus; // TODO: It should be safe to make this a bald pointer, since focus is always a child
Vector2 guiSize;
GuiResponse processNonFocus(const shared_ptr<InputObject>& event);
void switchFocus(GuiItem* item);
// Instance
/*override*/ void onDescendantRemoving(const shared_ptr<Instance>& instance);
/*override*/ bool askAddChild(const Instance* instance) const {
return Instance::fastDynamicCast<GuiItem>(instance)!=0;
}
/*override*/ const RBX::Name& getClassName() const {return RBX::Name::getNullName(); }
protected:
GuiItem* getFocus() {return focus.get();}
void loseFocus() {
if (focus) {
focus->onLoseFocus();
}
focus.reset();
}
Rect getMyRect(Canvas canvas) const; // myPosition, myPosition + mySize
Rect2D getMyRect2D(Canvas canvas) const {
return getMyRect(canvas).toRect2D();
}
void label2d(
Adorn* adorn,
const std::string& label,
const Color4& fill,
const Color4& border,
Text::XAlign align = Text::XALIGN_LEFT) const;
/////////////////////////////////////////////////////////////
//
// GUI Item virtuals
virtual void onLoseFocus() {}
virtual bool canLoseFocus() {return false;} // in general, Gui Items don't lose focus while processing
// standard virtual overrides....
virtual Vector2 getPosition(Canvas canvas) const {
RBXASSERT(getGuiParent());
return getGuiParent()->getChildPosition(this, canvas);
}
virtual Vector2 getChildPosition(const GuiItem* child, Canvas canvas) const { // This should always be override if ever used
RBXASSERT(0);
return Vector2::zero();
}
// used internally - could these be protected?
virtual int getFontSize() const {return 12;}
virtual bool isVisible() const {return true;}
virtual std::string getTitle() {return getName();}
public:
virtual Vector2 getSize(Canvas canvas) const {return getGuiSize();}
virtual GuiResponse process(const shared_ptr<InputObject>& event);
virtual void render2d(Adorn* adorn) {}
GuiItem();
~GuiItem();
void addGuiItem(shared_ptr<GuiItem> guiItem) {guiItem->setParent(this);}
void setGuiSize(const Vector2& size) {guiSize = size;}
const Vector2& getGuiSize() const {return guiSize;}
GuiItem* getGuiParent();
const GuiItem* getGuiParent() const;
GuiItem* getGuiItem(int index);
const GuiItem* getGuiItem(int index) const;
static const Color4& disabledFill();
static const Color4& translucentBackdrop();// background of the palette
static const Color4& menuSelect();
};
extern const char* const sGuiRoot;
class GuiRoot :
public Reflection::Described<GuiRoot, sGuiRoot, GuiItem, Reflection::ClassDescriptor::INTERNAL_LOCAL, RBX::Security::LocalUser>
{
public:
GuiRoot();
/*override*/ void render2d(Adorn* adorn);
void render2dItem(Adorn* adorn, GuiItem* guiItem);
// GuiItem
/*override*/ Vector2 getSize(Canvas canvas) const {
// shouldn't be called - implies item doesn't know it's top level
RBXASSERT(false);
return canvas.size;
}
protected:
virtual bool askSetParent(const Instance* instance) const {
return true;
}
};
class TopMenuBar : public GuiItem {
private:
void init();
protected:
Color4 backdropColor;
Layout::Style layoutStyle;
bool visible;
/*override*/ Vector2 getChildPosition(const GuiItem* child, Canvas canvas) const;
public:
TopMenuBar() {init();}
TopMenuBar(
const std::string& _title,
Layout::Style layoutStyle,
bool translucentBackdrop = false);
TopMenuBar(
const std::string& _title,
Layout::Style _layoutStyle,
Color4 _backdropColor);
/*override*/ GuiResponse process(const shared_ptr<InputObject>& event);
/*override*/ void render2d(Adorn* adorn);
/*override*/ Vector2 getSize(Canvas canvas) const;
/*override*/ bool isVisible() const {return visible;}
void setVisible(bool _set) {visible = _set;}
};
class RelativePanel : public TopMenuBar {
protected:
Rect::Location xLocation;
Rect::Location yLocation;
Vector2int16 offset;
void init(const Layout& layout);
public:
RelativePanel() {init(Layout());}
RelativePanel(const Layout& layout) {init(layout);}
virtual Vector2 getPosition(Canvas canvas) const;
};
// This will become the new unified widget - menu, button, all...
//
class UnifiedWidget : public GuiItem {
public:
enum MenuState {NOTHING, HOVER, SHOWN_APPEARING, SHOWN}; // + focus if child is shown
private:
typedef GuiItem Super;
MenuState menuState;
GuiResponse processShown_InTitle(const shared_ptr<InputObject>& event);
GuiResponse processShown_OutOfTitle(const shared_ptr<InputObject>& event);
GuiResponse processNothing(const shared_ptr<InputObject>& event);
GuiResponse processHover(const shared_ptr<InputObject>& event);
GuiResponse processShown(const shared_ptr<InputObject>& event);
GuiResponse processKey(const shared_ptr<InputObject>& event);
void render2dChildren(Adorn* adorn);
/*override*/ Vector2 getChildPosition(const GuiItem* child, Canvas canvas) const;
/*override*/ bool canLoseFocus() {return true;}
/*override*/ void onLoseFocus();
/*override*/ int getFontSize() const {return 8;}
void init();
protected:
bool showChildren() {return (menuState >= SHOWN_APPEARING);}
virtual void onMenuStateChanged() {}
virtual Vector2 firstChildPosition(Canvas canvas) const;
virtual Vector2 childOffset() const;
virtual void render2dMe(Adorn* adorn);
public:
UnifiedWidget() {init();}
UnifiedWidget(const std::string& title);
MenuState getMenuState() const {return menuState;}
void setMenuState(MenuState value);
/*override*/ GuiResponse process(const shared_ptr<InputObject>& event);
/*override*/ void render2d(Adorn* adorn);
};
class TextDisplay : public GuiItem {
private:
typedef GuiItem Super;
void init();
protected:
std::string label;
int fontSize;
Color4 fontColor;
Color4 borderColor;
Text::XAlign align;
bool visible;
/*override*/ int getFontSize() const {return fontSize;}
/*override*/ bool isVisible() const {return visible;}
const std::string& getLabel() const {return label;}
public:
TextDisplay() {init();}
TextDisplay(const std::string& title, const std::string& _label);
/*override*/ void render2d(Adorn* adorn);
/*override*/ Vector2 getSize(Canvas canvas) const;
void setLabel(const std::string& _label) {label = _label;}
void setFontSize(int _fontSize) {
fontSize = _fontSize;
setGuiSize(Vector2(fontSize*10.0f, fontSize*2.0f));
}
void setFontColor(const Color4& _color) {fontColor = _color;}
void setBorderColor(const Color4& _color) {borderColor = _color;}
void setAlign(Text::XAlign _align) {align = _align;}
void setVisible(bool _visible) {visible = _visible;}
};
} // namespace
+76
View File
@@ -0,0 +1,76 @@
/* Copyright 2003-2006 ROBLOX Corporation, All Rights Reserved */
#pragma once
#include "V8DataModel/GuiCore.h"
#include "V8Xml/Reference.h"
#include "Util/TextureId.h"
#include "GfxBase/TextureProxyBase.h"
#include "GfxBase/Adorn.h"
#include "rbx/signal.h"
namespace RBX {
class Adorn;
class GuiDrawImage
{
public:
enum ImageState
{
NORMAL = 0x1,
HOVER = 0x2,
DOWN = 0x4,
DISABLE = 0x8,
SELECTED = 0x10,
SELECTED_HOVER = 0x20,
SELECTED_DOWN = 0x40,
ALL = 0x7F
};
private:
TextureId currentTexture;
TextureId loadingTexture;
RBX::TextureProxyBaseRef disable;
RBX::TextureProxyBaseRef normal;
RBX::TextureProxyBaseRef hover;
RBX::TextureProxyBaseRef down;
RBX::TextureProxyBaseRef selected;
RBX::TextureProxyBaseRef selectedHover;
RBX::TextureProxyBaseRef selectedDown;
mutable Vector2 size;
rbx::signals::scoped_connection unbindResourceSignalHint;
void OnUnbindResourceSignalHint();
void draw(Adorn* adorn, const RBX::TextureProxyBaseRef& texture, const Rect& rect, const Vector2& texul, const Vector2& texbr, const Color4& color,
const Rect& clipRect, const Color4& behind, const Color4& inFront);
void draw(Adorn* adorn, const RBX::TextureProxyBaseRef& texture, const Rect& rect, const Vector2& texul, const Vector2& texbr, const Color4& color,
const Rotation2D& rotation, const Color4& behind, const Color4& inFront);
template <typename Modifier>
void render2dImpl(Adorn* adorn, bool enabled, const Rect& rect, const Vector2& texul, const Vector2& texbr, const Color4& color,
const Modifier& modifier, Gui::WidgetState state, bool isSelected);
void tryCreateTextureProxy(Adorn *adorn, const std::string& contentString, const std::string& context, RBX::TextureProxyBaseRef& textureRef, bool& isWaiting);
public:
GuiDrawImage() : size(Vector2(0,0)) {}
GuiDrawImage(Adorn *adorn, const std::string& textureName, unsigned imageState) {setImageFromName(adorn, textureName, imageState);}
void render2d(Adorn* adorn, bool enabled, const Rect& rect,
Gui::WidgetState state, bool isSelected);
void render2d(Adorn* adorn, bool enabled, const Rect& rect, const Vector2& texul, const Vector2& texbr, const Color4& color, const Rotation2D& rotation,
Gui::WidgetState state, bool isSelected);
void render2d(Adorn* adorn, bool enabled, const Rect& rect, const Vector2& texul, const Vector2& texbr, const Color4& color, const Rect& clipRect,
Gui::WidgetState state, bool isSelected);
void setImageSize(const Vector2& _size);
Vector2 getImageSize() const;
bool setImage(Adorn* adorn, const TextureId& textureId, unsigned imageState, Vector2* outSize = NULL, Instance* contextInstance = NULL, const char* context = "");
bool setImageFromName(Adorn* adorn, const std::string& textureName, unsigned imageState, Instance* contextInstance = NULL, const char* context = "");
void computeUV(Vector2& uvtl, Vector2& uvbr, const Vector2& imageRectOffset, const Vector2& imageRectSize, const Vector2& imageSize);
};
} // namespace
+62
View File
@@ -0,0 +1,62 @@
/* Copyright 2003-2015 ROBLOX Corporation, All Rights Reserved */
#pragma once
#include "v8tree/Instance.h"
LOGGROUP(GuiTargetLifetime)
namespace RBX {
class GuiResponse
{
private:
enum ResponseType {NOT_SUNK, SUNK};
enum FinishedType {NOT_FINISHED, FINISHED};
enum MouseOverType {NOT_MOUSE_OVER, MOUSE_OVER};
ResponseType response;
FinishedType finished;
MouseOverType mouseWasOver;
weak_ptr<Instance> target;
GuiResponse(ResponseType response, FinishedType finished, MouseOverType mouseWasOver, Instance* newTarget)
: response(response)
, finished(finished)
, mouseWasOver(mouseWasOver)
, target(weak_from(newTarget))
{}
GuiResponse(ResponseType response)
: response(response)
, finished(NOT_FINISHED)
, mouseWasOver(NOT_MOUSE_OVER)
{}
public:
GuiResponse()
: response(NOT_SUNK)
, finished(NOT_FINISHED)
, mouseWasOver(NOT_MOUSE_OVER)
{}
bool getMouseWasOver() const {return mouseWasOver == MOUSE_OVER;}
void setMouseWasOver() {mouseWasOver = MOUSE_OVER;}
bool wasSunk() {return (response == SUNK);}
bool wasSunkAndFinished()
{
RBXASSERT(!((finished == FINISHED) && !wasSunk()));
return (finished == FINISHED);
}
static GuiResponse notSunk() {return GuiResponse(NOT_SUNK);}
static GuiResponse notSunkMouseWasOver() {return GuiResponse(NOT_SUNK, NOT_FINISHED, MOUSE_OVER, NULL);}
static GuiResponse sunk() {return GuiResponse(SUNK);}
static GuiResponse sunkAndFinished() {return GuiResponse(SUNK, FINISHED, NOT_MOUSE_OVER, NULL);}
static GuiResponse sunkWithTarget(Instance* target) {return GuiResponse(SUNK, NOT_FINISHED, NOT_MOUSE_OVER, target);}
shared_ptr<Instance> getTarget() { return target.lock(); }
void setTarget(Instance* value) { target = weak_from(value); }
};
} // namespace
+29
View File
@@ -0,0 +1,29 @@
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
#pragma once
#include "Util/Rect.h"
#include "Util/G3DCore.h"
namespace RBX {
class Layout
{
public:
enum Style {HORIZONTAL = 0, VERTICAL = 1};
Rect::Location xLocation;
Rect::Location yLocation;
Vector2int16 offset;
Style layoutStyle;
Color4 backdropColor;
Layout()
: xLocation(Rect::LEFT)
, yLocation(Rect::TOP)
, offset(Vector2int16(0,0))
, layoutStyle(HORIZONTAL)
, backdropColor(Color4::clear())
{}
};
} // namespace
+35
View File
@@ -0,0 +1,35 @@
/* Copyright 2003-2006 ROBLOX Corporation, All Rights Reserved */
#pragma once
#include "Util/ScopedSingleton.h"
namespace RBX {
class WordList
{
private:
std::set<std::string> blacklist;
void decrypt(std::string& str);
public:
WordList();
~WordList();
bool ContainsProfanity(std::string str);
};
class ProfanityFilter : public ScopedSingleton<ProfanityFilter>
{
private:
WordList *wordlist;
bool ContainsProfanityWorker(std::string str);
public:
ProfanityFilter();
~ProfanityFilter();
static bool ContainsProfanity(const std::string& str);
};
} // namespace
+14
View File
@@ -0,0 +1,14 @@
/* Copyright 2003-2008 ROBLOX Corporation, All Rights Reserved */
#pragma once
#include "Gui/Gui.h"
#include "Util/RunStateOwner.h"
#include "Network/Player.h"
#include "Network/Players.h"
#include "V8DataModel/team.h"
#include "V8DataModel/teams.h"
namespace RBX {
} // namespace
+47
View File
@@ -0,0 +1,47 @@
/* Copyright 2003-2005 ROBLOX Corporation, All Rights Reserved */
#pragma once
#include "Gui/GUI.h"
#include "V8Tree/Verb.h"
#include "V8DataModel/GuiCore.h"
#include "v8datamodel/InputObject.h"
namespace RBX {
class Widget : public GuiItem
{
private:
typedef GuiItem Super;
GuiResponse processMouse(const shared_ptr<InputObject>& event);
GuiResponse processKey(const shared_ptr<InputObject>& event);
protected:
Gui::WidgetState widgetState;
// This should be standard for all widgets, verb widets, etc.
/*override*/ GuiResponse process(const shared_ptr<InputObject>& event);
/*override*/ void onLoseFocus() {
widgetState = Gui::NOTHING;
Super::onLoseFocus();
}
/////////////////////////////////////////////////////////
//
// Override these to make new widgets
// GUI ITEM
/*override*/ void render2d(Adorn* adorn);
// WIDGET
virtual void onClick(const shared_ptr<InputObject>& event) {}
virtual int getFontSize() const {return 10;}
virtual G3D::Color4 getFontColor() {return G3D::Color3::white();}
virtual bool isEnabled() {return isVisible();}
public:
Widget();
};
} // namespace