mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-13 20:07:07 +02:00
Added browser as a tool
This commit is contained in:
parent
7ab8b5a843
commit
c07ba9fec5
5 changed files with 37 additions and 4 deletions
|
@ -665,7 +665,8 @@ function checkController(deltaTime) {
|
|||
|
||||
moveOverlays();
|
||||
}
|
||||
|
||||
var newModel;
|
||||
var browser;
|
||||
function initToolBar() {
|
||||
toolBar = new ToolBar(0, 0, ToolBar.VERTICAL);
|
||||
// New Model
|
||||
|
@ -676,6 +677,12 @@ function initToolBar() {
|
|||
visible: true,
|
||||
alpha: 0.9
|
||||
});
|
||||
browser = toolBar.addTool({
|
||||
imageURL: toolIconUrl + "list-icon.png",
|
||||
width: toolWidth, height: toolHeight,
|
||||
visible: true,
|
||||
alpha: 0.7
|
||||
});
|
||||
}
|
||||
|
||||
function moveOverlays() {
|
||||
|
@ -780,6 +787,23 @@ function mousePressEvent(event) {
|
|||
var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y});
|
||||
|
||||
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();
|
||||
if (url == null || url == "") {
|
||||
return;
|
||||
|
|
|
@ -90,11 +90,18 @@ Tool = function(properties, selectable, selected) { // selectable and selected a
|
|||
return selected;
|
||||
}
|
||||
this.select = function(doSelect) {
|
||||
if (!selectable) {
|
||||
return;
|
||||
}
|
||||
|
||||
selected = doSelect;
|
||||
properties.subImage.y = (selected ? 2 : 1) * properties.subImage.height;
|
||||
Overlays.editOverlay(this.overlay(), { subImage: properties.subImage });
|
||||
}
|
||||
this.toggle = function() {
|
||||
if (!selectable) {
|
||||
return;
|
||||
}
|
||||
selected = !selected;
|
||||
properties.subImage.y = (selected ? 2 : 1) * properties.subImage.height;
|
||||
Overlays.editOverlay(this.overlay(), { subImage: properties.subImage });
|
||||
|
|
|
@ -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`
|
||||
QScriptValue WindowScriptingInterface::showS3Browse(const QString& nameFilter) {
|
||||
ModelsBrowser browser(ENTITY_MODEL);
|
||||
browser.setNameFilter(nameFilter);
|
||||
if (nameFilter != "") {
|
||||
browser.setNameFilter(nameFilter);
|
||||
}
|
||||
QEventLoop loop;
|
||||
connect(&browser, &ModelsBrowser::selected, &loop, &QEventLoop::quit);
|
||||
QMetaObject::invokeMethod(&browser, "browse", Qt::QueuedConnection);
|
||||
|
|
|
@ -31,7 +31,7 @@ public slots:
|
|||
QScriptValue form(const QString& title, QScriptValue array);
|
||||
QScriptValue prompt(const QString& message = "", const QString& defaultText = "");
|
||||
QScriptValue browse(const QString& title = "", const QString& directory = "", const QString& nameFilter = "");
|
||||
QScriptValue s3Browse(const QString& nameFilter = "..*");
|
||||
QScriptValue s3Browse(const QString& nameFilter = "");
|
||||
|
||||
private slots:
|
||||
QScriptValue showAlert(const QString& message);
|
||||
|
|
|
@ -182,7 +182,7 @@ ModelHandler::ModelHandler(ModelType modelsType, QWidget* parent) :
|
|||
QObject(parent),
|
||||
_initiateExit(false),
|
||||
_type(modelsType),
|
||||
_nameFilter(".*fst")
|
||||
_nameFilter(".*(fst|fbx|FST|FBX)")
|
||||
{
|
||||
// set headers data
|
||||
QStringList headerData;
|
||||
|
|
Loading…
Reference in a new issue