Added browser as a tool

This commit is contained in:
Atlante45 2014-07-17 17:50:56 -07:00
parent 7ab8b5a843
commit c07ba9fec5
5 changed files with 37 additions and 4 deletions

View file

@ -665,7 +665,8 @@ function checkController(deltaTime) {
moveOverlays(); moveOverlays();
} }
var newModel;
var browser;
function initToolBar() { function initToolBar() {
toolBar = new ToolBar(0, 0, ToolBar.VERTICAL); toolBar = new ToolBar(0, 0, ToolBar.VERTICAL);
// New Model // New Model
@ -676,6 +677,12 @@ function initToolBar() {
visible: true, visible: true,
alpha: 0.9 alpha: 0.9
}); });
browser = toolBar.addTool({
imageURL: toolIconUrl + "list-icon.png",
width: toolWidth, height: toolHeight,
visible: true,
alpha: 0.7
});
} }
function moveOverlays() { function moveOverlays() {
@ -780,6 +787,23 @@ function mousePressEvent(event) {
var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y}); var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y});
if (newModel == toolBar.clicked(clickedOverlay)) { if (newModel == toolBar.clicked(clickedOverlay)) {
var url = Window.prompt("Model URL", modelURLs[Math.floor(Math.random() * modelURLs.length)]);
if (url == null || url == "") {
return;
}
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(Quat.getFront(MyAvatar.orientation), SPAWN_DISTANCE));
if (position.x > 0 && position.y > 0 && position.z > 0) {
Models.addModel({ position: position,
radius: radiusDefault,
modelURL: url
});
} else {
print("Can't create model: Model would be out of bounds.");
}
} else if (browser == toolBar.clicked(clickedOverlay)) {
var url = Window.s3Browse(); var url = Window.s3Browse();
if (url == null || url == "") { if (url == null || url == "") {
return; return;

View file

@ -90,11 +90,18 @@ Tool = function(properties, selectable, selected) { // selectable and selected a
return selected; return selected;
} }
this.select = function(doSelect) { this.select = function(doSelect) {
if (!selectable) {
return;
}
selected = doSelect; selected = doSelect;
properties.subImage.y = (selected ? 2 : 1) * properties.subImage.height; properties.subImage.y = (selected ? 2 : 1) * properties.subImage.height;
Overlays.editOverlay(this.overlay(), { subImage: properties.subImage }); Overlays.editOverlay(this.overlay(), { subImage: properties.subImage });
} }
this.toggle = function() { this.toggle = function() {
if (!selectable) {
return;
}
selected = !selected; selected = !selected;
properties.subImage.y = (selected ? 2 : 1) * properties.subImage.height; properties.subImage.y = (selected ? 2 : 1) * properties.subImage.height;
Overlays.editOverlay(this.overlay(), { subImage: properties.subImage }); Overlays.editOverlay(this.overlay(), { subImage: properties.subImage });

View file

@ -205,7 +205,9 @@ QScriptValue WindowScriptingInterface::showBrowse(const QString& title, const QS
/// \return QScriptValue file path as a string if one was selected, otherwise `QScriptValue::NullValue` /// \return QScriptValue file path as a string if one was selected, otherwise `QScriptValue::NullValue`
QScriptValue WindowScriptingInterface::showS3Browse(const QString& nameFilter) { QScriptValue WindowScriptingInterface::showS3Browse(const QString& nameFilter) {
ModelsBrowser browser(ENTITY_MODEL); ModelsBrowser browser(ENTITY_MODEL);
browser.setNameFilter(nameFilter); if (nameFilter != "") {
browser.setNameFilter(nameFilter);
}
QEventLoop loop; QEventLoop loop;
connect(&browser, &ModelsBrowser::selected, &loop, &QEventLoop::quit); connect(&browser, &ModelsBrowser::selected, &loop, &QEventLoop::quit);
QMetaObject::invokeMethod(&browser, "browse", Qt::QueuedConnection); QMetaObject::invokeMethod(&browser, "browse", Qt::QueuedConnection);

View file

@ -31,7 +31,7 @@ public slots:
QScriptValue form(const QString& title, QScriptValue array); QScriptValue form(const QString& title, QScriptValue array);
QScriptValue prompt(const QString& message = "", const QString& defaultText = ""); QScriptValue prompt(const QString& message = "", const QString& defaultText = "");
QScriptValue browse(const QString& title = "", const QString& directory = "", const QString& nameFilter = ""); QScriptValue browse(const QString& title = "", const QString& directory = "", const QString& nameFilter = "");
QScriptValue s3Browse(const QString& nameFilter = "..*"); QScriptValue s3Browse(const QString& nameFilter = "");
private slots: private slots:
QScriptValue showAlert(const QString& message); QScriptValue showAlert(const QString& message);

View file

@ -182,7 +182,7 @@ ModelHandler::ModelHandler(ModelType modelsType, QWidget* parent) :
QObject(parent), QObject(parent),
_initiateExit(false), _initiateExit(false),
_type(modelsType), _type(modelsType),
_nameFilter(".*fst") _nameFilter(".*(fst|fbx|FST|FBX)")
{ {
// set headers data // set headers data
QStringList headerData; QStringList headerData;